![](/img/trans.png)
[英]MFMailComposeViewController didFinishWithResult not being called
[英]messageComposeViewController didFinishWithResult delegate method not being called
我有一个视图控制器“ Paircontroller”,它呈现了MFMessageComposeViewController,如下所示:
NSArray *recpts = [[NSArray alloc]initWithObjects:phone.text, nil];
MFMessageComposeViewController *mcontr = [[MFMessageComposeViewController alloc]init];
mcontr.body = @"Sign up for our app!";
mcontr.recipients = recpts;
mcontr.subject = @"hey!";
mcontr.delegate = self;
[self presentViewController:mcontr animated:YES completion:^{
}];
该视图控制器的界面如下所示:
@interface PairViewController : UIViewController<UITextFieldDelegate,CustomIOS7AlertViewDelegate, UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate>
@end
在视图控制器的实现中,我定义了委托方法- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
如下:
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
case MessageComposeResultCancelled:
NSLog(@"Cancelled");
break;
case MessageComposeResultFailed:
NSLog(@"unknown error sending m");
break;
case MessageComposeResultSent:
NSLog(@"Message sent successfully");
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:^{}];
}
但是,未调用委托方法(未命中断点,也未命中NSLogs)。
有人可以帮我解决为什么它不起作用吗?
谢谢!
C
我认为以下更改应该有效。 MFMessageComposeViewController
是UINavigationController
子类,因此在原始代码中,您将UINavigationControllerDelegate
设置为self。
mcontr.messageComposeDelegate = self;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.