屏幕旋转

2019-12-12  本文已影响0人  傲骨天成科技

本文涉及到的转屏是咱们的app的某个页面设置横竖屏的切换

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
   return UIInterfaceOrientationPortrait; 
}  
  1. 状态栏是否隐藏
 - (BOOL)prefersStatusBarHidden {
 return NO; // your own visibility code
}

5.点击某个按钮进行横屏


- (void)switchToLandscape
{
 self.a = 1;
 [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeRight] forKey:@"orientation"];
 [UIViewController attemptRotationToDeviceOrientation];

}

6.点击某个按钮进行竖屏

 - (void)switchToPortrait
{
  self.a = 0;
  [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
  [UIViewController attemptRotationToDeviceOrientation];
}

上一篇下一篇

猜你喜欢

热点阅读