IOS如何使用代码管控APP页面横竖屏切换?
这个我写了个小demo,下载链接 http://code4app.com/ios/53c78e77933bf098108b4ea0
1。⾸首先是AppDelegate,这⾥里加载rootViewController⽅方法要变⼀下 :
- (BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.window = [[UIWindow alloc]initWithFrame:screenBounds];
LoadingViewController * mainViewController =[[LoadingViewController alloc] init];
rootNavigationController * navigationController = [[rootNavigationController alloc]
initWithRootViewController:mainViewController];
[window setRootViewController:navigationController];
[self.window makeKeyAndVisible];
return YES;
}
LoadingViewController就是我的⼀一个⻚页⾯面,我让LoadingViewController作为我的主⻚页⾯面。

本文介绍了一个iOS应用如何通过代码控制页面横竖屏切换。通过自定义rootNavigationController并重写相关方法,结合调整AppDelegate配置,实现对各个页面横竖屏的支持。同时强调了在页面切换时应避免使用pushViewController,而应使用presentViewController来正确处理横竖屏转换。

402

被折叠的 条评论
为什么被折叠?



