objective-c – 在iOS 6中获取当前界面方向
发布时间:2020-12-14 19:55:55 所属栏目:百科 来源:网络整理
导读:我在iOS 5.x中动态进行方向检查,如下所示: -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ if(interfaceOrientation == UIInterfaceOrientationPortrait||interfaceOrientation == UIInterfaceOrientationP
我在iOS 5.x中动态进行方向检查,如下所示:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if(interfaceOrientation == UIInterfaceOrientationPortrait||interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { self.viewProfile.frame = CGRectMake(238,612,295,73); // some more settings } else { self.profileNew.frame = CGRectMake(374,540,58); // some more settings } return YES; } 对于iOS 6,我做了以下代码,但那不起作用: -(BOOL)shouldAutorotate{ return YES; } -(NSInteger)supportedInterfaceOrientations { if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)) { self.viewProfile.frame = CGRectMake(238,73); // some more settings } else { self.profileNew.frame = CGRectMake(374,58); // some more settings } return UIInterfaceOrientationMaskAll; } 如何像在iOS 5.x中一样检查iOS 6中的界面内容? 谢谢 解决方法
您可以使用viewWillLayoutSubviews方法,在该方法中检查方向
[[UIApplication sharedApplication] statusBarOrientation]; 并相应地设置您的帧. 希望这可以帮助! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |