[英]iPhone - getting device orientation in first view controller's view will appear
[英]i want to know device orientation when the view will appear IOS 6
我想知道视图出现时的设备方向。 以前可以使用shouldAutorotateToInterfaceOrientation
方法,但在IOS 6中它已被弃用。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation==UIInterfaceOrientationPortrait ||interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown ) {
DashBtn.hidden=NO;
}
else
{
DashBtn.hidden=YES;
if (self.popoverControllerMain) {
[self.popoverControllerMain dismissPopoverAnimated:YES];
}
}
return YES;
}
我检查了所有帖子,即制作rootviewcontroller和
- (BOOL)shouldAutorotate {
return NO;
}// this method is not called
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
尝试使用
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
代替
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
创建UINavigationController的类别并添加以下代码@implementation UINavigationController(Rotation_IOS6)
- (BOOL)shouldAutorotate {return [[self.viewControllers lastObject] shouldAutorotate]; }
- (NSUInteger)supportedInterfaceOrientations {return [[self.viewControllers lastObject] supportedInterfaceOrientations]; }
@结束
了解设备方向的最佳选择是
[[UIApplication sharedApplication] statusBarOrientation]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.