IOS开发——判断屏幕的方向

来源:互联网 发布:网络安全隐患有案例 编辑:程序博客网 时间:2024/06/17 10:07

IOS开发——判断屏幕的方向

方法一:

- (void)viewDidLoad {    //判断屏幕方向    UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {            }else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight) {            }else if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {            }else{            }    }

方法二:

//直接以屏幕方向判断- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {       //home健在左    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {            //home健在右    }else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight) {            //home健在下    }else if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {            }else{            }    }



0 0
原创粉丝点击