无法在 iOS7 中显示模态 ViewController [英] Cannot show modal ViewController in iOS7

查看:24
本文介绍了无法在 iOS7 中显示模态 ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将系统定义的视图控制器(MFMailComposeViewController、TWTweetComposeViewController 等)显示为模态视图.

I tried to show system defined viewcontrollers (MFMailComposeViewController, TWTweetComposeViewController,etc..) as a modal view.

但是这些视图控制器不会出现在 iOS 7 中(这些在 iOS5、iOS6 中运行).

But these viewcontrollers dosn't appear in iOS 7(these run in iOS5,iOS6).

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

Viewcontrollers created by me appear in iOS7(ex.HogeViewController).

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

I don't call presentViewController:animated:completion at viewDidLoad or viewWillAppear.

有人有想法吗?

控制台日志:

init Error Domain=NSCocoaErrorDomain Code=4097 操作无法完成.(Cocoa 错误 4097.)"

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

_serviceViewControllerReady:error: Error Domain=NSCocoaErrorDomain Code=4097操作无法完成.(Cocoa 错误 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(doesn't appear)

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

日志

结果:0

MFMailComposeViewController(出现一会儿消失)

MFMailComposeViewController(appears a moment and dismiss soon)

- (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 操作无法完成.(Cocoa 错误 4097.)"对 的开始/结束外观转换的不平衡调用.错误:(空),结果:0

_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 位应用程序中使用以下内容,则会出现问题:

Turns out the issue only shows up when customizing UIBarButtons. If we use the following in our 32-bit app running on iPhone 5s, we have the problem:

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

省去那条线可以解决这个问题.我们已经提交了雷达.

Leaving out that line works around the problem. We have filed a radar.

这篇关于无法在 iOS7 中显示模态 ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆