作者:爱唱歌的郭少文_ | 来源:互联网 | 2023-01-15 10:34
我有一个奇怪的问题,我只是做一个简单的呈现模态视图控制器.MFMailComposeViewController
确切地说.但是,它出现在呈现控制器后面,因此您无法发送任何电子邮件或类型.您可以UINavigationBar
在邮件编辑器上看到"取消"按钮,但会弹出UIAlertController
显示控制器的后面.这是怎么发生的?这是iOS 11问题吗?对于UIAlertController
s 我也有类似的行为.
此外,如果我按下发送并按下我的按钮以弹出另一个Composer,它将正常工作.这只是第一个.
请参阅我从Xcode获得的附图.
![在此输入图像描述](https://img.php1.cn/3cd4a/1eebe/cd5/dc7ef30f57b727c7.jpeg)
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
@interface AboutViewController ()
@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@email.com"]];
[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代表的想法.这向我展示了它第一次有一个不同的过渡代表,第二次有我想要的那个.
问题是navigationController在解除我在顶部的控制器(菜单控制器)之前推动了新的控制器.一个简单的修复,但因为它在开始时并不明显,没有错误日志,所以很难确定.