您的位置:首页 > 其它

所有界面锁定屏幕方向,某一个界面支持屏幕旋转~

2015-10-16 10:25 429 查看
//appdelagate.h 加
@property (nonatomic, assign) BOOL allowRotation;

//appdelegate.m加
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  if (self.allowRotation) {
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
  }
  return UIInterfaceOrientationMaskPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
  return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationPortrait;
}

打开屏幕旋转:

  AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

  delegate.allowRotation = YES;

关闭屏幕旋转:

  AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

  delegate.allowRotation = NO;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: