gpt4 book ai didi

objective-c - AppDelegate 中的方向检测

转载 作者:行者123 更新时间:2023-12-01 16:54:40 25 4
gpt4 key购买 nike

这是在我的 AppDelegate 中,并在方向更改时运行。当应用程序加载时,它总是以纵向模式加载。如果我在设备处于横向模式时加载应用程序,这仍然会像设备处于纵向模式一样执行。这是我遇到的第一个问题。第二个是加载后,当我将设备从纵向旋转到横向时,会出现断线,如下所示:

-(void)setOrientationView
{

UIDevice *currentDevice = [UIDevice currentDevice];
[currentDevice endGeneratingDeviceOrientationNotifications];
UIDeviceOrientation theOr = currentDevice.orientation;

if ( UIDeviceOrientationIsLandscape(theOr) && !isLandVisible )
{
NSLog(@"setLand");
isLandVisible = YES;
isPortVisible = NO;

[self.window.rootViewController pushViewController:portCont animated:YES]; // <Thread 1: breakpoint 2.1

}

if( UIDeviceOrientationIsPortrait(theOr) && !isPortVisible )
{
NSLog(@"setPort");
isPortVisible = YES;
isLandVisible = NO;

[self.window.rootViewController pushViewController:portCont animated:YES];

}
[currentDevice beginGeneratingDeviceOrientationNotifications];

}

我正在努力支持加载时的两个方向,使用 Storyboard 应用程序,并且在查看 View 后不关闭 View (防止重新加载 UIWebViews 所必需的)。所以有两个问题超出了我的范围。谢谢。

最佳答案

Advanced App Tricks iOS App Programming Guide 的部分有一些关于 Launching in Landscape Mode 的指南。 ,您的答案可能就在这几行之内(如果可能的话)。特别要照顾UIInterfaceOrientation在您的 Info.plist文件。

关于objective-c - AppDelegate 中的方向检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12771377/

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