美文网首页
iOS-屏幕旋转调用与监听的方法

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

作者: 无悔zero | 来源:发表于2016-11-22 11:06 被阅读439次

- (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) {}

相关文章

网友评论

      本文标题:iOS-屏幕旋转调用与监听的方法

      本文链接:https://www.haomeiwen.com/subject/upuppttx.html