gpt4 book ai didi

iphone 方向问题..

转载 作者:行者123 更新时间:2023-11-29 13:26:27 26 4
gpt4 key购买 nike

我遇到了关于 iPhone 屏幕方向的问题。我的应用程序的基础 sdk 是 ios 6.0,部署目标是 4.3 并在 ios 5.0 和 5.1 上运行

在应用程序的 plist 文件中,我设置了 Portrait(底部主页按钮)Landscape(左侧主页按钮)Landscape(右侧主页按钮) .我正在开发一个通用应用程序。因此,在每个 View 的 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 方法中,我有条件地为 iphone 返回 portrait,为 ipad 返回 landscape

我的导航流程是:

UINavigatinController 推送 UITableViewControler 第一个选项卡有 UINavigationControllerrootViewController 上一个接一个地推送 2 个 View 。

在我最后一个 viewController 的 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 方法中,我返回了 YES。但是这个 View 的应用程序根本没有旋转。甚至不调用 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 方法。 :(

我的要求是只支持一个 viewController 而不是整个应用程序的横向和纵向方向。

请帮帮我。

最佳答案

您可以通过 View Controller 类中的这段代码解决这个方向问题。

#ifdef IOS_OLDER_THAN_6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);

}
#endif

#ifdef IOS_NEWER_OR_EQUAL_TO_6
-(BOOL)shouldAutorotate {

return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight); //IOS_5
}
#endif

您必须在 .pch 文件中定义此代码。

代码:

 #define IOS_OLDER_THAN_6  ([[[UIDevice currentDevice] systemVersion] floatValue] < 6.0)
#define IOS_NEWER_OR_EQUAL_TO_6 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)

希望它有效。

谢谢。

关于iphone 方向问题..,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13009740/

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