// - 有时我们调用了这个方法 并且实现了屏幕旋转相关的代码但是屏幕还是没有旋转过来 有可能导致这个问题的原因是我们多次调用了移除
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
这个通知的问题 如果加入一次通知 移除一次通知没有问题,但是如果加入过一次通知但是移除通知两次,就会出现问题
2.有时候我们应该悬转的视图控制没有调用 shouldAutorotate 方法 导致视图控制一直没有旋转 那么可能是 下边的方法中一直返回 UIInterfaceOrientationMaskAllButUpsideDown 导致没有调用系统的 shouldAutorotate 方法
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window {
if (self.supportLandscape) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
return UIInterfaceOrientationMaskPortrait;
}
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
#pragma mark - 设备旋转
-(BOOL)shouldAutorotate{
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
最后
以上就是谦让母鸡最近收集整理的关于iOS 导致横屏失败的bug 的原因分析之一的全部内容,更多相关iOS内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复