2017-10-06 319 views
5

我有一个奇怪的问题,我只是做一个简单的呈现模态视图控制器。准确地说是MFMailComposeViewController。但是,它出现在呈现控制器后面,因此您不能发送任何电子邮件或类型。您可以在邮件编辑器上看到UINavigationBar上的“取消”按钮,但弹出展示控制器后面的UIAlertController。这是怎么发生的?它是一个iOS 11的问题?我也得到了类似的行为UIAlertControlleriOS 11 presentViewController后面呈现控制器

此外,如果我按发送并按下我的按钮弹出另一个作曲家,它将正常工作。这只是第一个。

请参阅附加的图像,我从Xcode。

enter image description here

MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 
mailer.mailComposeDelegate = self; 
mailer.modalPresentationStyle = UIModalPresentationFormSheet; 
[mailer setSubject:@"subject Feedback"]; 
[mailer setToRecipients:@[@"email address"]]; 
[mailer setMessageBody:@"" isHTML:NO]; 
[self presentViewController:mailer animated:YES completion:nil]; 

编辑:添加控制器的详细信息。

#import "AboutViewController.h" 
#import <MessageUI/MessageUI.h> 


@interface AboutViewController() <MFMailComposeViewControllerDelegate> 
@property (nonatomic, strong) IBOutlet UIView *contentView; 
@end 

@implementation AboutViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.title = @"About this app"; 
    _contentView.layer.cornerRadius = 10.; 
    _contentView.layer.shadowColor = [UIColor blackColor].CGColor; 
    _contentView.layer.shadowRadius = 3.; 
    _contentView.layer.shadowOpacity = 0.4; 
    _contentView.layer.shadowOffset = CGSizeMake(3., 3.); 
    // Do any additional setup after loading the view from its nib. 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (IBAction)sendFeedbackEmail:(id)sender { 
    if ([MFMailComposeViewController canSendMail]){ 
     dispatch_async(dispatch_get_main_queue(), ^{ 
      MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 
      mailer.mailComposeDelegate = self; 
      mailer.modalPresentationStyle = UIModalPresentationFormSheet; 
      [mailer setSubject:@"Feedback"]; 
      [mailer setToRecipients:@[@"[email protected]"]]; 
      [mailer setMessageBody:@"" isHTML:NO]; 
      [self presentViewController:mailer animated:YES completion:nil]; 

     }); 
    } else { 
     NSLog(@"Nope"); 
    } 
} 

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

编辑2:

我相信我已经找到了答案。我希望这可以帮助任何遇到同样问题的人。谢谢你所有的答复,它帮助我找到答案。谢谢@Mert Buran的代表意见。这表明我第一次有一个不同的过渡代表,并且第二次有我想要的过渡代表。

问题是导航控制器在关闭控制器之前推了新的控制器(菜单控制器)。一个简单的解决方法,但因为它在开始时并不明显,并且没有错误日志,所以难以确定点。

+0

此外,我已将此置于主线程以避免任何混淆 – mashdup

+0

您可以将项目上传到Github吗? – LinusGeffarth

+0

不幸的是我不能。但我将不得不使用另一种解决方案,感谢您寻找 – mashdup

回答

相关问题