【发布时间】:2013-11-17 08:57:09
【问题描述】:
我创建了一个只能在横向模式下工作的应用程序。启动画面正常工作,但在启动画面之后,我的第一页没有设置为横向模式。我附上了屏幕截图,在这里我给出了支持方向方法的代码。我通过打印它显示的值来检查边界大小 0,0,768,1024 但我想要 0,0,1024,768.
//checking the frame size
CGRect theRect = self.view.bound;
NSLog(@" frame %f %f %f %f", theRect.origin.x,
theRect.origin.y,
theRect.size.width,
theRect.size.height);
//orientation method
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
UIInterfaceOrientation crntOrntatn = self.interfaceOrientation;
return UIInterfaceOrientationIsLandscape(crntOrntatn) ? crntOrntatn : UIInterfaceOrientationLandscapeLeft;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
【问题讨论】:
-
你的 rootViewController 是什么?是 UIViewcontroller 还是 UINavigationCONtroller?
-
它的 UIViewController。 [self.window setRootViewController:lenseHomePageObj];
-
只是想确认一下,它来自 self.interfaceOrientation?
-
它在我的首页类中。
-
好的,在您首选的InterfaceOrientationForPresentation 方法中,只需输入 [[UIApplication sharedApplication] statusBarOrientation] 而不是 self.interfaceOrientation
标签: ios objective-c ipad uinavigationcontroller