gpt4 book ai didi

iphone - 在一个 View Controller 中强制肖像使其他 View Controller 最初处于肖像

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:43:00 25 4
gpt4 key购买 nike

导航 Controller 的 Root View Controller 仅支持纵向,其他 Controller 支持所有方向。现在如果我在 Root View Controller 上并且设备处于横向并且如果我按下一个纵向打开的下一个 View Controller 应该打开在景观中,因为它支持所有方向。

请帮我解决这个问题。

使用 iPhone 4s iOS6.1.3

最佳答案

您可以在使用以下代码登录 View Controller 后在第一个屏幕中检查设备方向:-

-(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
}

所以当你加载这个 View Controller 时,它首先检查设备方向,然后加载它的相关框架

关于iphone - 在一个 View Controller 中强制肖像使其他 View Controller 最初处于肖像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16710899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com