- (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;
}
}
我有上面的代码,正常显示短信窗口.. 它工作正常并发送短信,但发送或取消后SMS窗口不会关闭.. NSLog注册发送或取消,但SMS窗口不会消失!
有人可以帮忙吗? 谢谢 垫
答案 0 :(得分:0)
你必须自己使用
解雇它[self dismissViewControllerAnimated:YES completion:^{ // something to do on completion if you need}];