我的应用程序允许用户通过iMessenger发送短信。问题是,对于第一个消息,它工作正常,但是控制器为空且呈灰色,并且当他们发送第二条消息时,没有取消按钮。仅当他们没有互联网时,才会发生这种情况。当他们有互联网时,它发送的很好。如果没有互联网,是否可以“存储” iMessage并允许将多个消息添加到同一号码?
-(void)textbuttoniphone:(UIButton *)sender
{
NSLog(@"TEXT 6");
dispatch_async(dispatch_get_main_queue(), ^{
MFMessageComposeViewController *composeVC = [[MFMessageComposeViewController alloc] init];
composeVC.messageComposeDelegate = self;
NSString * textmessage = self.record.textmessage;
NSString * savedValue = self.shareModeOverlayView.textingfield.text;
NSLog (@"SAVED VALUE: %@", savedValue);
if (![MFMessageComposeViewController canSendText])
{
NSLog(@"NO CAN'T SEND");
[nonpressTimer invalidate];
nonpressTimer = [NSTimer scheduledTimerWithTimeInterval:25.0 target:self
selector:@selector(timeout) userInfo:nil repeats:NO];
}
else
{
NSArray * usersTo = [NSArray arrayWithObject:[NSString stringWithFormat:@"%@", savedValue]];
[composeVC setRecipients:usersTo];
[composeVC setBody: textmessage];
[self presentViewController:composeVC animated:YES completion:nil];
}
}
然后在发送时我有这个。
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result
{
if (result == MessageComposeResultSent) {
NSLog(@"Sent");
[controller dismissViewControllerAnimated:YES completion:nil];
myview.hidden = YES;
}
else if (result == MessageComposeResultCancelled) {
[controller dismissViewControllerAnimated:YES completion:nil];
myview.hidden = NO;
}
}