1.方法一:当屏幕变化时会自动调用此方法
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
if (interfaceOrientation==UIInterfaceOrientationPortrait) {
}else if (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown){
}else if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft){
}else if (interfaceOrientation==UIInterfaceOrientationLandscapeRight){
}
}
2.方法二:通过比较宽高判断
if ([UIScreen mainScreen].bounds.size.width>[UIScreen mainScreen].bounds.size.height) {
//横屏
}else{
//竖屏
}
转载请注明原文地址: https://ju.6miu.com/read-1312680.html