ios6和ios7禁止屏幕旋转

时间:2023-12-11 11:18:08

ios6和ios7禁止屏幕旋转

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

{

return (toInterfaceOrientation == UIInterfaceOrientationPortrait);

}

- (BOOL)shouldAutorotate

{

return NO;

}

- (NSUInteger)supportedInterfaceOrientations

{

return UIInterfaceOrientationMaskPortrait;//只支持这一个方向(正常的方向)

}这些方法不行

再。。。。。

在appdelegate中添加如下代码

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

return UIInterfaceOrientationMaskAll;

else  /* iphone */

return UIInterfaceOrientationMaskPortrait ;

}