1. <tfoot id='mBoxE'></tfoot>
  2. <legend id='mBoxE'><style id='mBoxE'><dir id='mBoxE'><q id='mBoxE'></q></dir></style></legend>

      • <bdo id='mBoxE'></bdo><ul id='mBoxE'></ul>
    1. <i id='mBoxE'><tr id='mBoxE'><dt id='mBoxE'><q id='mBoxE'><span id='mBoxE'><b id='mBoxE'><form id='mBoxE'><ins id='mBoxE'></ins><ul id='mBoxE'></ul><sub id='mBoxE'></sub></form><legend id='mBoxE'></legend><bdo id='mBoxE'><pre id='mBoxE'><center id='mBoxE'></center></pre></bdo></b><th id='mBoxE'></th></span></q></dt></tr></i><div id='mBoxE'><tfoot id='mBoxE'></tfoot><dl id='mBoxE'><fieldset id='mBoxE'></fieldset></dl></div>

      <small id='mBoxE'></small><noframes id='mBoxE'>

      点击 MFMailComposeViewController 的取消按钮时,操作表不显示

      时间:2023-10-03

      <small id='Z1fBd'></small><noframes id='Z1fBd'>

          <tfoot id='Z1fBd'></tfoot>
            • <bdo id='Z1fBd'></bdo><ul id='Z1fBd'></ul>
              <legend id='Z1fBd'><style id='Z1fBd'><dir id='Z1fBd'><q id='Z1fBd'></q></dir></style></legend>
                <tbody id='Z1fBd'></tbody>

                <i id='Z1fBd'><tr id='Z1fBd'><dt id='Z1fBd'><q id='Z1fBd'><span id='Z1fBd'><b id='Z1fBd'><form id='Z1fBd'><ins id='Z1fBd'></ins><ul id='Z1fBd'></ul><sub id='Z1fBd'></sub></form><legend id='Z1fBd'></legend><bdo id='Z1fBd'><pre id='Z1fBd'><center id='Z1fBd'></center></pre></bdo></b><th id='Z1fBd'></th></span></q></dt></tr></i><div id='Z1fBd'><tfoot id='Z1fBd'></tfoot><dl id='Z1fBd'><fieldset id='Z1fBd'></fieldset></dl></div>
                本文介绍了点击 MFMailComposeViewController 的取消按钮时,操作表不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试将 MFMailComposeViewController 合并到我的应用程序中.当我以模态方式呈现它时,发送按钮可以正常工作并发送电子邮件,这意味着在这种情况下发送给委托人的结果是正确的.

                I'm trying to incorporate MFMailComposeViewController in my app. When I present it modally, the send button works fine and the email is sent, which implies that the result sent to the delegate is right in that case.

                而当我点击取消按钮时,它会挂断应用程序.日志也没有显示任何错误,只是屏幕变暗,一切都被禁用.显然,结果没有传递给委托(我通过日志检查了它).看来

                Whereas when I tap the cancel button it hangs up the app. The log shows no errors either, just the screen goes dark and everything gets disabled. Apparently, the result is not being passed to the delegate (I checked it through logs). it appears that the

                (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
                

                永远不会在按下取消按钮时调用.可能这就是未显示操作表(保存草稿取消删除草稿)的原因,因此应用程序就挂在那里了.

                is never called whenever the cancel button is pressed. Probably that's the reason why the actionsheet (Save draft, cancel, delete draft) is not displayed and therefore the app hangs in right there.

                我正在使用来自 Apple 示例应用程序 (MailComposer) 的确切代码,它在那里完美运行,但不知何故我的失败了.:(

                I'm using the exact code from Apple's sample apps (MailComposer), it works perfectly there, but somehow fails in mine. :(

                如果有人遇到过同样的问题并成功解决,请帮助我.

                Kindly help me if anyone has ever come across the same issue, and successfully resolved it.

                我的代码:

                  -(IBAction)emailButtonPressed:(id)sender{
                
                           Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
                       if (mailClass != nil)
                          {
                
                          if ([mailClass canSendMail])
                            {
                              [self displayComposerSheet];
                            }
                          else
                            {
                              [self launchMailAppOnDevice];
                            }
                          }
                        else
                          {
                            [self launchMailAppOnDevice];
                          }
                
                
                }
                
                
                #pragma mark -
                #pragma mark Compose Mail
                
                
                -(void)displayComposerSheet 
                {
                    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
                    picker.mailComposeDelegate = self;
                
                    [picker setSubject:@"Ilusiones"];
                
                
                    // Set up recipients
                     NSArray *toRecipients = [NSArray arrayWithObject:@"anam@semanticnotion.com"]; 
                
                     [picker setToRecipients:toRecipients];
                     // Attach a screenshot to the email      
                     UIGraphicsBeginImageContext(self.view.bounds.size);
                     [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
                     UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
                     UIGraphicsEndImageContext();
                
                         NSData *myData = UIImagePNGRepresentation(viewImage);
                     [picker addAttachmentData:myData mimeType:@"image/png" fileName:@"viewImage"];
                
                
                
                     // Fill out the email body text
                     NSString *emailBody = @"";
                     [picker setMessageBody:emailBody isHTML:NO];
                
                     [self presentModalViewController:picker animated:YES];
                         [picker release];
                
                 }
                
                 - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
                 {  
                
                  switch (result)
                  {
                case MFMailComposeResultCancelled:
                    NSLog(@"Result: canceled");
                    break;
                case MFMailComposeResultSaved:
                    NSLog(@"Result: saved");
                    break;
                case MFMailComposeResultSent:
                    NSLog( @"Result: sent");
                    break;
                case MFMailComposeResultFailed:
                    NSLog( @"Result: failed");
                    break;
                default:
                    NSLog(@"Result: not sent");
                    break;
                 }
                 [self dismissModalViewControllerAnimated:YES];
                }
                
                
                #pragma mark -
                #pragma mark Workaround
                
                
                -(void)launchMailAppOnDevice
                {
                NSString *recipients = @"mailto:anam@semanticnotion.com.com?cc=second@example.com,third@example.com&subject=illusions!";
                NSString *body = @"&body=xyz";
                
                NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
                email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
                }
                

                推荐答案

                方法

                (void)mailComposeController:(MFMailComposeViewController*)controller
                        didFinishWithResult:(MFMailComposeResult)result
                                      error:(NSError*)error
                

                永远不会被调用,因为您在取消后没有按任何 UIActionSheet 按钮,因为它不会显示在屏幕上.

                is never called because you don't press any UIActionSheet button after cancelling, as it doesn't show on screen.

                发生这种情况的原因是 UIActionSheet 出现在屏幕外.如果您检查调试日志,您可能会看到一条消息,说 Prepresenting action sheet 被其超级视图剪辑.某些控件可能无法响应触摸. 在 iPhone 上尝试 -[UIActionSheet showFromTabBar:]-[UIActionSheet showFromToolbar:] 而不是 -[UIActionSheetshowInView:]."

                The reason this is happening is that the UIActionSheet appears off-screen. If you check the debug log you'll probably see a message saying Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:]."

                这就是为什么您会看到视图变暗,但没有出现 UIActionSheet.

                That's why you see your view getting darker, but no UIActionSheet appears.

                就我而言,问题是我的应用程序是通用的,但由于某种原因,只有一个 MainWindow.xib,而且它比 iPhone 的屏幕尺寸大(实际上是,iPad 屏幕尺寸).

                In my case, the problem was that my app is universal, but for some reason there was only one MainWindow.xib, and it was larger than the iPhone screen size (it was, in fact, the iPad screen size).

                解决方案是创建另一个具有正确尺寸的 MainWindow-iPhone.xib 并更改名为 Main nib file base (iPad) 的 Info.plist 条目>主 nib 文件库 (iPhone) 以便它们指向正确的文件.问题解决了!

                The solution is to create another MainWindow-iPhone.xib with the right dimensions and change the Info.plist entries called Main nib file base (iPad) and Main nib file base (iPhone) so that they point to the right file. Problem solved!

                希望对你有帮助.

                这篇关于点击 MFMailComposeViewController 的取消按钮时,操作表不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何通过 iPhone 应用程序单击一次按钮在 Facebook 墙上发布图像 下一篇:为什么设置 UIWindow 的 rootViewController 属性时 viewDidLoad 会被调用两次?

                相关文章

                <legend id='i98rv'><style id='i98rv'><dir id='i98rv'><q id='i98rv'></q></dir></style></legend>

                <i id='i98rv'><tr id='i98rv'><dt id='i98rv'><q id='i98rv'><span id='i98rv'><b id='i98rv'><form id='i98rv'><ins id='i98rv'></ins><ul id='i98rv'></ul><sub id='i98rv'></sub></form><legend id='i98rv'></legend><bdo id='i98rv'><pre id='i98rv'><center id='i98rv'></center></pre></bdo></b><th id='i98rv'></th></span></q></dt></tr></i><div id='i98rv'><tfoot id='i98rv'></tfoot><dl id='i98rv'><fieldset id='i98rv'></fieldset></dl></div>

                    <bdo id='i98rv'></bdo><ul id='i98rv'></ul>

                1. <small id='i98rv'></small><noframes id='i98rv'>

                2. <tfoot id='i98rv'></tfoot>