在一个视图控制器中强制肖像使其他人最初处于肖像 [英] Force portrait in one view controller makes other to be in portrait initially
问题描述
导航控制器的根视图控制器仅支持纵向方向,其他控制器支持所有方向.现在,如果我在根视图控制器上并且设备处于横向状态,并且如果我按下下一个应以纵向打开的视图控制器在景观中,因为它支持所有方向.
The root view controller of navigation controller supports only portrait orientation and other controllers supports all orientation.Now if i am on the root view controller and the DEVICES is in landscape and if i push next view controller that opens in portrait that should open in landscape as it supports all orientation.
请帮助我.
使用iPhone 4s iOS6.1.3
Using iPhone 4s iOS6.1.3
推荐答案
您可以使用以下代码在登录ViewController后在第一个屏幕中检查设备方向:-
you can check Device orientation in your first screen after login viewcontroller using bellow code:-
-(void)viewWillAppear:(BOOL)animated
{
[self willRotateToOrientation:[[UIDevice currentDevice] orientation]];
[super viewWillAppear:YES];
}
- (void)willRotateToOrientation:(UIInterfaceOrientation)newOrientation {
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
if (newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight) {
//set your landscap View Frame
[self supportedInterfaceOrientations];
}
}
else if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
if(newOrientation == UIInterfaceOrientationPortrait || newOrientation == UIInterfaceOrientationPortraitUpsideDown){
//set your Potrait View Frame
[self supportedInterfaceOrientations];
}
}
// Handle rotation
}
或者在加载此ViewController时先检查设备排列,然后加载其相关框架
sor when you load this viewcontroller it check first device oriantation and then load it's related frame
这篇关于在一个视图控制器中强制肖像使其他人最初处于肖像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!