gpt4 book ai didi

ios - 未调用 messageComposeViewController didFinishWithResult 委托(delegate)方法

转载 作者:行者123 更新时间:2023-12-01 17:22:30 25 4
gpt4 key购买 nike

我有一个显示 MFMessageComposeViewController 的 View Controller “Paircontroller”,如下所示:

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:^{
}];

这个 View Controller 的界面如下所示:
@interface PairViewController : UIViewController<UITextFieldDelegate,CustomIOS7AlertViewDelegate, UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate>

@end

在 View Controller 的实现中,我定义了委托(delegate)方法 - (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:^{}];
}

但是,没有调用委托(delegate)方法(没有命中断点,也没有命中 NSLogs)。

有人可以帮我解决为什么这不起作用吗?

谢谢!

C

最佳答案

我认为以下更改应该有效。 MFMessageComposeViewControllerUINavigationController子类,因此在您的原始代码中设置 UINavigationControllerDelegate对自己。

mcontr.messageComposeDelegate = self;

关于ios - 未调用 messageComposeViewController didFinishWithResult 委托(delegate)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28421414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com