gpt4 book ai didi

iOS 11 presentViewController 落后于呈现 Controller

转载 作者:可可西里 更新时间:2023-11-01 04:55:21 25 4
gpt4 key购买 nike

我遇到了一个奇怪的问题,我只是在做一个简单的呈现模态视图 Controller 。 MFMailComposeViewController 确切地说。但是,它出现在呈现 Controller 的后面,因此您无法发送任何电子邮件或类型。您可以在邮件编写器的 UINavigationBar 上看到“取消”按钮,但这会弹出呈现 Controller 后面的 UIAlertController。这是怎么发生的?这是iOS 11的问题吗? UIAlertController 也有类似的行为。

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

请查看我从 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];

编辑:添加 Controller 以获取更多信息。

#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@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 的代表想法。这向我展示了它第一次有一个不同的转换委托(delegate),而我第二次想要的是一个。

问题是导航 Controller 在关闭我在顶部的 Controller (菜单 Controller )之前推送了新 Controller 。一个简单的修复,但因为它在开始时并不明显并且没有错误日志,所以很难确定。

最佳答案

我会在您的 viewDidLoad 中尝试 self.definesPresentationContext = YES。见 https://developer.apple.com/documentation/uikit/uiviewcontroller/1621456-definespresentationcontext

关于iOS 11 presentViewController 落后于呈现 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46610051/

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