我试图将系统定义的 View Controller (MFMailComposeViewController、TWTweetComposeViewController 等)显示为模态视图。
但这些 View Controller 不会出现在 iOS 7 中(它们在 iOS5、iOS6 中运行)。
我创建的 Viewcontroller 出现在 iOS7 中(ex.HogeViewController)。
我不会在 viewDidLoad
或 viewWillAppear
调用 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/