在iOS7中无法显示模态ViewController

前端之家收集整理的这篇文章主要介绍了在iOS7中无法显示模态ViewController前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图将系统定义的视图控制器(MFMailComposeViewController,TWTweetComposeViewController等)显示为模态视图.

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

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

我不调用presentViewController:动画:在viewDidLoad完成或viewWillAppear.

有人有想法吗?

控制台日志:

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相关文章