简体   繁体   English

在MFMessageComposeViewController中点击取消后没有任何反应

[英]After hitting cancel in a MFMessageComposeViewController nothing happens

After though that after using MFMailComposeViewController the move to MFMessageComposeViewController was straight foward, but there is a catch. 虽然在使用MFMailComposeViewController ,移动到MFMessageComposeViewController是直接的,但有一个问题。

Suppose this code: 假设这段代码:

MFMessageComposeViewController* mySMS = [[MFMessageComposeViewController alloc] init];
[mySMS setDelegate:self];
[self presentModalViewController:mySMS animated:YES];

It works this way for mails, but in sms you should set different the delegate to an internal structure like this: 它以这种方式用于邮件,但在短信中你应该将委托设置为不同的内部结构,如下所示:

[SMS setMessageComposeDelegate:self];

Hope you don not get stuck on this as I did early today. 希望你不要像今天早些时候那样陷入困境。

You need to Implement the delegate method -(void)mailComposeController(MFMailComposeViewController*)controller didFinishWithResult (MFMailComposeResult)result error:(NSError*)error: 您需要实现委托方法-(void)mailComposeController(MFMailComposeViewController*)controller didFinishWithResult (MFMailComposeResult)result error:(NSError*)error:

And inside it you should dismiss it yourself: 在它里面你应该自己解雇它:

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
    [self dismissModalViewControllerAnimated:YES]; 
}

You can see MFMailComposeResult in Apple documentation 您可以在Apple文档中看到MFMailComposeResult

  enum MFMailComposeResult {
    MFMailComposeResultCancelled,
    MFMailComposeResultSaved,
    MFMailComposeResultSent,
    MFMailComposeResultFailed
 };
 typedef enum MFMailComposeResult MFMailComposeResult; 

And you must dismiss controller by yourself in delegate method 你必须在委托方法中自己解雇控制器

 - (void) mailComposeController:(MFMailComposeViewController *)controller          didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
 {
  switch (result){
    case MFMailComposeResultCancelled:
        NSLog(@"Mail cancelled");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Mail saved");
        break;
    case MFMailComposeResultSent:
        NSLog(@"Mail sent");
        break;
    case MFMailComposeResultFailed:
        NSLog(@"Mail sent failure: %@", [error localizedDescription]);
        break;
    default:
        break;
   }
// Close the Mail Interface
   [self dismissViewControllerAnimated:YES completion:NULL];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MFMessageComposeViewController后键盘未显示 - Keyboard not showing after MFMessageComposeViewController MFMessageComposeViewController上的“取消”按钮未显示 - Cancel button on MFMessageComposeViewController does not show up 取消在蓝色导航栏中的MFMessageComposeViewController上不可见 - Cancel not visible on MFMessageComposeViewController in blue color navigation bar 用鲨鱼分析iphone:按下开始后没有任何反应 - Profiling iphone with shark: Nothing happens after pressing start shouldAutorotateToInterfaceOrientation但没有任何反应 - shouldAutorotateToInterfaceOrientation but nothing happens 切换ViewController,但是什么也没发生? - Switching ViewControllers, but nothing happens? UI元素在显示MFMessageComposeViewController后滑动 - UI elements slide after showing MFMessageComposeViewController MFMessageComposeViewController之后,iPhone opengl支持变为w = 0 h = 0 - iphone opengl backing becomes w=0 h=0 after MFMessageComposeViewController 在iOS 8中旋转后MFMailComposeViewController和MFMessageComposeViewController的边界错误 - MFMailComposeViewController and MFMessageComposeViewController have wrong bounds after rotation in iOS 8 应用内购买,展示产品但没有任何反应 - In-app purchase, show products but nothing happens
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM