2012-02-20 50 views
3

我正在创建仅支持LANDSDCAPE模式的iPad应用程序。我正在使用故事板。只有横向方向的故事板ipad

即使在执行以下操作后,模拟器在横向模式下启动时,应用程序仅以纵向模式启动。请帮助我如何让应用程序在横向模式下启动并始终保持该模式。

  1. shouldautorotate被设置为YES景观
  2. 在info.plist中
  3. 初始界面朝向被设置为风景
  4. 在info.plist中
  5. 支持的接口方向设置为风景
  6. 为viewcontrollers模拟度量被设置为推断。

在此先感谢您的帮助。我在网上搜索过,但没有答案。

回答

6

在模拟度量下选择“横向”。

另外,还要确保你在你的视图控制器实现此方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); 
} 
+0

这样做,但是这并没有解决问题。 – inforeqd 2012-02-20 04:49:30

+1

@user,您是否将shouldAutorotateToInterfaceOrientation方法添加到所有视图控制器实现?请参阅上面的代码。 – 2012-02-20 05:49:34

+2

是的,谢谢你! :-)我通过将故事板类指向UIviewController类的一个子类来解决问题,其中shouldAutorotateToInterfaceOrientation也被编码。这必须为每个实现的ViewController完成。这是我的错误(oops!);-( 我认为故事板会自行处理景观实现,但我想它不会直到我们将UIViewController子类与它关联起来。直接在故事板中,不编码shouldAutorotateToInterfaceOrientation ??? 感谢您的回答 – inforeqd 2012-02-20 23:29:07