【问题标题】:viewWillAppear incorrect orientation when presentViewController without a navigation view controller当 presentViewController 没有导航视图控制器时,viewWillAppear 方向不正确
【发布时间】:2015-03-19 13:19:14
【问题描述】:

我遇到了一个奇怪的问题,我在景观中并提出了一个 VC

SomeViewController * vc = [[SomeViewController alloc] init];
[self.navigationController presentViewController:vc animated:YES completion:^{

}];

viewWillAppear 框架不正确地处于纵向,而在viewDidAppear正确地处于横向

但是当我把它放在 UINavigationController 中时

SomeViewController * vc = [[SomeViewController alloc] init];
UINavigationController * nc = [[UINavigationController alloc] initWithRootViewController:vc];

[self.navigationController presentViewController:nc animated:YES completion:^{

}];

viewWillAppear 框架是正确的横向

这是一个错误吗?我错过了什么吗?为什么会这样?

【问题讨论】:

    标签: ios cocoa-touch uiviewcontroller uiinterfaceorientation


    【解决方案1】:

    我认为这是设计使然,请参阅此答案 A: View frame changes between viewWillAppear: and viewDidAppear:

    viewDidAppear 框架几何是正确的,因为它现在在屏幕上并添加到视图层次结构中,但我实际上建议在 viewDidLayoutSubviews 中执行此操作,因为旋转方向时也会调用它。

    【讨论】:

      猜你喜欢
      • 2014-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-08
      • 1970-01-01
      • 2018-08-27
      相关资源
      最近更新 更多