【问题标题】:how to set orientation to correct device orientation after dismissModalViewController?如何在dismissModalViewController 后设置方向以更正设备方向?
【发布时间】:2012-05-18 10:29:07
【问题描述】:

我有一个显示内容的详细视图。通过一个按钮,我以模态方式呈现另一个视图:

[self.viewController presentModalViewController:helpViewController animated:NO];  

因此,当我关闭此 helpViewController 时,detailview 始终处于 PortraitMode。
无法将其调整到正确的设备方向。

我已经尝试过将其旋转到设备方向:

if ([UIViewController respondsToSelector:@selector(  
    attemptRotationToDeviceOrientation)]) {

    [UIViewController attemptRotationToDeviceOrientation];
}  

似乎在关闭 helpViewController 后 viewDidAppear 没有在 detailView 中调用。
那么我怎样才能让它工作呢?

【问题讨论】:

    标签: ios uiviewcontroller rotation orientation landscape-portrait


    【解决方案1】:

    请尝试将 detailview.m 设置为

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

    【讨论】:

    • shouldAutorotateToInterfaceOrientation 的返回值已经设置为YES,但是还是不行。
    • detailview的父视图呢?
    • 那么在出现 helpView 之前所有的都旋转好?
    • 完全正确。刚从helpview返回时,detailview被锁定在portraidMode。
    • 哦,不是。但不知道为什么。这里有什么问题?
    猜你喜欢
    • 1970-01-01
    • 2011-12-19
    • 2014-01-26
    • 2020-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-28
    • 1970-01-01
    相关资源
    最近更新 更多