Ios8 如何在iOS 8中显示半透明(半切)viewcontroller

Ios8 如何在iOS 8中显示半透明(半切)viewcontroller,ios8,presentviewcontroller,uimodalpresentationstyle,Ios8,Presentviewcontroller,Uimodalpresentationstyle,在iOS 7中,此方法没有问题: _rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext; [_rootViewController presentViewController:self animated:NO completion:nil]; 但在iOS 8中,它什么也没做。如何解决它?这是iOS 8的Bug吗 注意,xcode6_beta7上需要此解决方法。最新xcode6 已修复UIMo

在iOS 7中,此方法没有问题:

_rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[_rootViewController presentViewController:self animated:NO completion:nil];
但在iOS 8中,它什么也没做。如何解决它?这是iOS 8的Bug吗

注意,xcode6_beta7上需要此解决方法。最新xcode6 已修复UIModalPresentationOver*样式。所以,我只是将它们分配给myModalViewController.modalPresentationStyle,现在它可以正常工作了

在阅读了和之后,终于在iOS 8中实现了

您可以使模态视图控制器从UIViewControllerTransitioningDelegate继承

@interface MyModalController : UIViewController <UIViewControllerTransitioningDelegate>
返回从UIPresentationController继承的TransparentPresentationController实例

@interface TransparentPresentationController : UIPresentationController
和覆盖应删除PresenterView

- (BOOL) shouldRemovePresentersView {
    return NO;
}

我的答案更简单,下面是代码。这在iOS8(XCode6-GM-seed)中起作用


我在另一个场景中写这个:我在两个场景中写这个:在ViewController:-(iAction)present:(id)sender{//scene two SecondViewController*controller=[[SecondViewController alloc]init];[controller present];}在第二个场景中:-(void)present{UIViewController*root=[[[[UIApplication sharedApplication]委托]窗口]rootViewController];[self-setTransitioningDelegate:self.transitionController];self.modalPresentationStyle=UIModalPresentationCustom;[root-presentViewController:self-animated:YES完成:nil];}但它没有执行委托方法。为什么?你的是对的。我覆盖了shouldRemovePresentersView以返回否。但我仍然无法访问presenters视图。如果在vc视图中旋转应用程序,viewForKey将返回nil发生了什么?在我的应用程序中,当方法-(BOOL)应该自动旋转{返回NO;}时,它会旋转。如果使用的是展开序列,则可能需要在展开序列处理程序中显式调用dismissViewController以使视图消失。
@interface TransparentPresentationController : UIPresentationController
- (BOOL) shouldRemovePresentersView {
    return NO;
}
HogeViewController *vc = [[HogeViewController alloc] init];
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:vc animated:NO completion:nil];