读书人

ios 6中怎么禁止横屏

发布时间: 2012-12-15 15:16:03 作者: rapoo

ios 6中如何禁止横屏
ios 6中如何禁止横屏

- (BOOL)shouldAutorotate

{

return NO;

}

把plist里面的Supported interface orientation 相关横屏的设置删掉后


- (BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}


以上方法都试过了,无效
[解决办法]
1. 可以在项目属性(高版本的xcode)里把两个方向的横屏设置为禁止


2. 这个方法是可以用的,如果不能用,可能是哪里出了问题


- (BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

[解决办法]
In ios6 禁止横屏,
- (BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

建议你参考 blog.csdn.net/totogogo/article/details/8002173
[解决办法]
在AppDelegate中增加,这个方法可以禁止横屏

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}
[解决办法]
你这个方法是全局都不能横屏吧。。好牵强的结贴理由。。呵呵

读书人网 >Iphone

热点推荐