我有一个由很多视图控制器组成的应用程序......在项目摘要中,我将纵向方向设置为唯一受支持的设备方向.
但是,当转向侧面时,应用程序仍然会搞砸.
我的问题是,有没有办法通过app委托或其他方式全局禁用自动旋转?
或者我是否必须进入所有视图控制器并添加"shouldAutorotateToInterfaceOrientation"方法?
只是不想错过将它添加到一个或一个......
谢谢!
Vai*_*ran 16
现在有三种设备方向键info.plist.
第三个是我认为非通用应用程序,其余两个是针对iPad和iPhone.
你应该试一试.

kar*_*rim 11
在努力设置UIViewController shouldAutorotate和supportedInterfaceOrientation方法之后,在iOS6中没有成功,我发现最有效的是在app delegate中设置它.
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
然而,返回UIInterfaceOrientationMaskPortraitUpsideDown正在崩溃我的应用程序.我不知道我做错了什么!
在根视图控制器的方法中:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
Run Code Online (Sandbox Code Playgroud)
设置'返回NO';
这应该适用于所有视图.
| 归档时间: |
|
| 查看次数: |
31627 次 |
| 最近记录: |