iOS-屏幕旋转调用与监听的方法

2016-11-22  本文已影响439人  无悔zero

- (BOOL)shouldAutorotate {

//返回是否允许转屏

return YES;

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{

//返回所支持的旋转方向

return    UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{

//返回初始化显示的方向

return    UIInterfaceOrientationMaskLandscapeLeft;

}

注册通知监听屏幕旋转方法名:UIApplicationDidChangeStatusBarOrientationNotification

获取当前屏幕方向:UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

if(orientation == UIInterfaceOrientationLandscapeLeft){}

else if (orientation == UIInterfaceOrientationLandscapeRight) {}

上一篇 下一篇

猜你喜欢

热点阅读