我想将MFMailComposeViewController mailComposeDelegate
属性与完成块语法一起使用,但不确定这是否可能。类似于TWTweetComposeViewController completionHandler
属性的工作方式:
TWTweetComposeViewController __weak *twee = tweeter;
tweeter.completionHandler = ^(TWTweetComposeViewControllerResult result) {
// code here
};
我创建的代码创建了 MFMailComposeViewController,但随后必须保存对我的viewController
参数的引用,因为此“通过电子邮件共享”功能不在 a 中UIViewcontroller
,而是在自定义MYSharing
类中。
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
// more code here
_viewController = viewController;
picker.mailComposeDelegate = self;
[viewController presentModalViewController:picker animated:YES];
来自MFMailComposeViewControllerDelegate使用它mailComposeController:didFinishWithResult:error:
来关闭模式。_viewController
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[_viewController dismissModalViewControllerAnimated:YES];
}
不是很好理解块,有没有一些看起来像这样的语法?
picker.mailComposeDelegate = ^(???)(??? ??? ???) {
[viewController dismissModalViewControllerAnimated:YES];
}
我确实找到了MFMailComposeViewController(BlocksKit)(在 github 上有源代码),但即便如此,语法转换还是让我感到困惑。