【问题标题】:how to change orientation of UIViewController to Landscape programmatically?如何以编程方式将 UIViewController 的方向更改为横向?
【发布时间】:2012-02-01 01:57:07
【问题描述】:

我想更改使用presentModalViewController 显示的 UIViewController 的方向...我在网上看到了几个解决方案(包括 SO)。但是,它们都没有解决我的问题。

我在这里播放一些视频,想将屏幕方向更改为横向 .. 有什么帮助吗?

谢谢。

使用这段代码,我部分解决了我的问题:(我的视图控制器只为 LandscapeLEFT 做景观,而不是为 LandscapeRIGHT==>为 LandscapeRight,它仍然在视图控制器中进行 LandscapeLEFT 方向更改)......有什么帮助吗?? ??????????

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

【问题讨论】:

  • 您要强制旋转,还是允许旋转?

标签: ios orientation landscape


【解决方案1】:

试试这个: 返回 [YES] 将确保您的应用支持所有界面操作。

  • (BOOL) 应该自动旋转到接口方向:(UIInterfaceOrientation interfaceOrientation { // 对于支持的方向返回 YES 返回是; }

【讨论】:

  • 我目前正在使用这个:- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation != UIInterfaceOrientationPortrait); } else { return YES; } } 但没有帮助:(
猜你喜欢
  • 2023-03-09
  • 2017-11-15
  • 2012-05-27
  • 1970-01-01
  • 1970-01-01
  • 2010-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多