![](/img/trans.png)
[英]ViewController from .xib file is loading in portrait mode and not in landscape mode in iOS
[英]iOS: Switching to Portrait ViewController from LandScape ViewController
我在Portrait中有一個VC,它提供了另一個可以是縱向或橫向的VC。 問題在於,當我返回展示它的原始VC時,它也會以橫向顯示,直到我旋轉它,然后再保持縱向。 我想要的是始終擁有原始的VC始終是肖像,我該如何實現? 在我在PList中設置受支持的方向之后,這里是用於設置VC方向的代碼:
在原始的VC中,應該始終是縱向的
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
在我的VC中可以是縱向或橫向的,我有:
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
重寫supportedInterfaceOrientations方法,並返回UIInterfaceOrientationMaskPortraitUpsideDown。
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortraitUpsideDown;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.