[英]IOS 7: Transparent Viewcontroller Background over another Viewcontroller with different Orientation behaviour
我有2个ViewController(IOS7),我想显示第一个而不是第一个,具有透明的背景和不同的方向行为。
例如:按下第一个ViewController上的按钮将调出第二个ViewController,但是第一个在背景上仍将在第二个ViewController的透明区域中可见。 如果旋转手机,则只有第二个ViewController旋转,而第一个(背景中的一个)保持相同方向。
有什么建议么? 谢谢!
您可以在第一个上以模态形式显示第二个ViewController,第一个具有UIModalPresentationCurrentContext类型的modalPresentationStyle 。
如果您的第一个ViewController嵌入在UINavigationController之类的ContainerViewController中,则必须在该容器上设置modalPresentationStyle,并需要在其上显示第二个ViewController。
在您的第一个ViewController中,它看起来像:
- (void)buttonTapped:(id)sender {
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self.navigationController presentViewController:[SecondViewController new] animated:YES completion:nil];
}
当然,您还必须为支持的界面方向配置/实现所需的行为。 例如,通过重写第二个ViewController中的supportedInterfaceOrientations() ,如下所示:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.