iOS 7系统中,此方法没有任何问题:
_rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[_rootViewController presentViewController:self animated:NO completion:nil];
但在 iOS 8 上它没有起作用。如何解决?这是 iOS 8 的一个 Bug 吗?
iOS 7系统中,此方法没有任何问题:
_rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[_rootViewController presentViewController:self animated:NO completion:nil];
但在 iOS 8 上它没有起作用。如何解决?这是 iOS 8 的一个 Bug 吗?
我的回答更简单,下面是代码。这个在iOS8(XCode6 GM seed)中有效。
HogeViewController *vc = [[HogeViewController alloc] init];
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:vc animated:NO completion:nil];
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
MyModalController *myModalController = [[MyModalController alloc] initWithNibName:@"MyModalController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myModalController];
navController.modalPresentationStyle = UIModalPresentationCustom;
navController.transitioningDelegate = myModalController;
[self.navigationController presentViewController:navController animated:YES completion:nil];
@interface MyModalController : UIViewController <UIViewControllerTransitioningDelegate>
并覆盖 presentationControllerForPresentedViewController:...
-(UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source
{
if (presented == self) {
return [[TransparentPresentationController alloc] initWithPresentedViewController:presented presentingViewController:presenting];
} else {
return nil;
}
}
@interface TransparentPresentationController : UIPresentationController
并且覆盖应该删除演示文稿视图
- (BOOL) shouldRemovePresentersView {
return NO;
}