- (IBAction)SendTxt:(id)sender {
MFMessageComposeViewController *textComposer = [[MFMessageComposeViewController alloc] init];
[textComposer setMessageComposeDelegate:self];
if ([MFMessageComposeViewController canSendText]) {
[textComposer setRecipients:[NSArray arrayWithObjects:@"123456",@"123456", nil]];
[textComposer setBody:@"HELP ME"];
[self presentViewController:textComposer animated:YES completion:NO];
}
else {
NSLog(@"Can't open Text");
}
}
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
case MessageComposeResultSent:
NSLog(@"SENT");
break;
case MessageComposeResultFailed:
NSLog(@"FAILED");
break;
case MessageComposeResultCancelled:
NSLog(@"CANCELLED");
break;
default:
break;
}
}
我有上面的代码可以正常打开短信窗口。它工作正常并发送短信,但发送或取消后短信窗口不会关闭。NSLog注册发送或取消但短信窗口不会消失!
任何人都可以帮忙吗?谢谢垫