【问题标题】:How to fix Orientation error in ipad?如何修复 ipad 中的方向错误?
【发布时间】: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


【解决方案1】:

检查应用委托。导航控制器已正确初始化?

【讨论】:

    猜你喜欢
    • 2016-04-30
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    • 2011-03-13
    • 1970-01-01
    相关资源
    最近更新 更多