【问题标题】:presentViewController width in landscape mode横向模式下的presentViewController宽度
【发布时间】:2017-03-08 12:35:29
【问题描述】:

在呈现视图控制器时,我希望它在 iPhone 移植模式下占据屏幕宽度/高度的 100%,但在横向模式下占据屏幕的一部分(像这样):

并且偏爱 iPad。以下代码执行除了 iPhone 横向部分之外的所有操作:

SQLProEditConnetionViewController * editConnectionViewController =
    [[SQLProEditConnetionViewController alloc] initWithConnectionModel: nil];

editConnectionViewController.delegate = self;

UINavigationController * navController =
    [[UINavigationController alloc] initWithRootViewController: editConnectionViewController];

navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle   = UIModalTransitionStyleCoverVertical;
navController.preferredContentSize   = CGSizeMake(320, 620); // size of popup view

[self presentViewController: navController
                   animated: YES
                 completion: nil];

有什么想法可以让它在 iPhone 横向模式下正常工作吗?

【问题讨论】:

  • 您可能希望使用容器视图来实现这一点,而不是仅仅在当前视图上显示UIViewController。查看来自 Apple 的文档:developer.apple.com/library/content/featuredarticles/…(尤其是使用 addChildViewController: 并将其框架设置为当前的 UIViewController)。

标签: ios objective-c uinavigationcontroller landscape


【解决方案1】:

在您的代码中更改: modalPresentationStyle

navController.modalPresentationStyle = UIModalPresentationFullScreen;

希望这会奏效...!!

【讨论】:

【解决方案2】:

在 iPhone 和 iPod touch 上,呈现的视图始终是全屏的。在 iPad 上,显示取决于 modalPresentationStyle 属性中的值。

【讨论】:

    【解决方案3】:

    原来我看到这个是因为 iPhone SE 模拟器。在较大的设备上,它可以按照我的意愿工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-14
      • 2016-12-01
      相关资源
      最近更新 更多