无法在iOS7中显示模态ViewController [英] Cannot show modal ViewController in iOS7
问题描述
我试图将系统定义的viewcontrollers(MFMailComposeViewController,TWTweetComposeViewController等)显示为模态视图。
I tried to show system defined viewcontrollers (MFMailComposeViewController, TWTweetComposeViewController,etc..) as a modal view.
但是这些viewcontrollers不会出现在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).
我不打电话给 presentViewController:animated:completion
at viewDidLoad
或 viewWillAppear
。
I don't call presentViewController:animated:completion
at viewDidLoad
or viewWillAppear
.
有人知道吗?
控制台日志:
init错误域= NSCocoaErrorDomain代码= 4097操作无法完成。(可可错误4097。)
init Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"
或
_serviceViewControllerReady:error:Error Domain = NSCocoaErrorDomain Code = 4097操作无法完成。(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(doesn't appear)
TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc]init];
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result){
NSLog(@"Result : %d",result);
};
[self presentViewController:viewController animated:YES completion:NULL];
日志
结果:0
Result : 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 error 4097.)
非平衡调用开始/结束外观转换。
错误:(null),结果: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屋!