【问题标题】:Modal in landscape orientation swaps to portrait when dismissed关闭时横向模式下的模式切换为纵向
【发布时间】:2013-12-02 21:03:05
【问题描述】:

我有一个 UINavigationController,我以模态方式呈现。模态正确地呈现在手机所在的方向上。但是,当我关闭模态时,它会立即旋转到纵向并动画到主页按钮,在横向模式下该按钮位于左侧或右侧。模式打开时导航一切正常,旋转很好,只是没有关闭。

我怎样才能简单地让模式在设备所在的方向上关闭?

我已包含在横向模式下被关闭的模态图像。

之前:

期间:

如您所见,布局非常混乱。 NavigationController 中显示的当前视图甚至不会调整为纵向屏幕尺寸。

值得一提的是,此时我还将展示一个新的 sotryboard

    _storyboard = [UIStoryboard storyboardWithName:storyBoardName bundle:resourceBundle];
    _rootViewController = [_storyboard instantiateInitialViewController];
   [_sourceViewController presentViewController:_rootViewController animated:animated completion:nil];

【问题讨论】:

  • 您是否只在横向使用第一个屏幕?
  • 检查故事板中其他视图控制器支持的方向。
  • 我不这么认为,除了倒置,所有屏幕都可以改变。
  • 我在所有viewcontrollers和uinavigationcontroller- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAllButUpsideDown; }
  • 底层视图控制器在第二张截图中不可见是不是也很奇怪?

标签: ios iphone objective-c uinavigationcontroller modalviewcontroller


【解决方案1】:

我相信我已经解决了自己的问题。从后台线程更新 UI - 经典。发生的事情是我从委托方法-(void)didLogin; 中触发了dismiss 方法。此委托方法在后台线程上的网络调用后触发。因此,当我尝试更新 UI 时,我不再在导致一些非常不寻常的 UI 行为的主线程上。

[[NSOperationQueue mainQueue] addOperationWithBlock:^ {}];

这节省了一天的时间。

【讨论】:

    猜你喜欢
    • 2012-03-05
    • 2014-05-11
    • 1970-01-01
    • 2010-10-24
    • 2011-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多