如何在横向模式下强制设备

时间:2011-04-23 11:53:20

标签: iphone

我有应用程序在该应用程序中以纵向模式运行,当我转到下一个视图时,我必须在横向模式下更改设备方向。有什么办法。

2 个答案:

答案 0 :(得分:1)

将以下代码放在您的控制器类中,以便在UIViewControllers之间具有不同的方向,

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

您也可以尝试在视图之间使用不同的方向。

[[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:(id)UIInterfaceOrientationLandscapeRight];

答案 1 :(得分:0)

没有。 [UIDevice setOrientation:]这样做,但它是私有API。

相关问题