ios - 无法在 iOS7 中显示模态 ViewController

标签 ios ios7

我试图将系统定义的 View Controller (MFMailComposeViewController、TWTweetComposeViewController 等)显示为模态视图。

但这些 View Controller 不会出现在 iOS 7 中(它们在 iOS5、iOS6 中运行)。

我创建的 Viewcontroller 出现在 iOS7 中(ex.HogeViewController)。

我不会在 viewDidLoadviewWillAppear 调用 presentViewController:animated:completion

有人有想法吗?

控制台日志:

init Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"

_serviceViewControllerReady:error: Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"

Unbalanced calls to begin/end appearance transitions for .

TWTweetComposeViewController(没有出现)

TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc]init];
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result){
    NSLog(@"Result : %d",result);
};
[self presentViewController:viewController animated:YES completion:NULL];

日志

Result : 0

MFMailComposeViewController(出现片刻,很快消失)

- (void)send:(NSString*)email{
    if ([MFMailComposeViewController canSendMail]) {
        MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        picker.mailComposeDelegate = self;

        NSArray *toRecipients = @[email];
        [picker setToRecipients:toRecipients];

        [picker setSubject:@"Subject"];
        [picker setMessageBody:@"Body" isHTML:NO];
        [self.navigationController presentViewController:picker animated:YES completion:NULL];
    }
}

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
    [self dismissViewControllerAnimated:YES completion:^{
        NSLog(@"error:%@,result:%d",error.description,result);
    }];
}

日志

_serviceViewControllerReady:error: Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)" Unbalanced calls to begin/end appearance transitions for . error:(null),result:0

最佳答案

原来这个问题只在自定义 UIBarButtons 时出现。如果我们在 iPhone 5s 上运行的 32 位应用程序中使用以下内容,就会遇到问题:

[[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, 1.0)
                                           forBarMetrics:UIBarMetricsDefault];

省略该行可以解决该问题。我们已经提交了雷达。

关于ios - 无法在 iOS7 中显示模态 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18978864/

相关文章:

iphone - 如何在sqlite查询中传递表名

ios - 如何在终端中通过 swift 打印?

ios - 使用自动布局的带有缩放 UIImageView 的 UIScrollView

ios - Swift - 为 SOAP Web 服务创建请求和解析响应

ios - 是否可以检查 iOS 7 中是否启用了 iCloud KeyChain?

objective-c - 在同一个应用程序中同时使用 Facebook API 和 Google Places API 的 JSON 库问题

ios - 将 Stripe token 推送到 Cloud Function Firebase (iOS Swift 3)

iphone - UITableViewCell 背景颜色与 alpha 不同的行为

ios - 如何在 AVPlayer IOS 中使用 URL 播放 youtube 视频?

ios - 具有不同自动旋转选项的屏幕