【问题标题】:ModalViewController dimensions on orientation change方向更改时的 ModalViewController 尺寸
【发布时间】:2012-12-28 11:20:08
【问题描述】:

我在supportedInterfaceOrientations 方法中设置了UIInterfaceOrientationMaskAll。 当我展示UIModalViewController 时,无论屏幕旋转如何,我总是得到 748 x 1024 的视图尺寸。如果我旋转屏幕,尺寸不会更新,并且在纵向和横向模式下是相同的:748 x 1024。

这是呈现模态视图的代码:

MyModalViewController *myModal = [[MyModalViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:myModal animated:YES];

MyModalViewController 扩展了另一个 MyCUSTOMViewController,它是 UIViewController 的子类:

@interface MyModalViewController : MyCUSTOMViewController

@interface MyCUSTOMViewController : UIViewController

我做错了什么?

【问题讨论】:

    标签: iphone ios orientation modalviewcontroller dimensions


    【解决方案1】:

    根据我的阅读,有几点需要考虑:

    1. 要在整个应用中提供其他方向,您必须在应用的 UIApplicationDelegate 中覆盖 -(NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window,并返回 UIInterfaceOrientationMaskAll
    2. 在您的自定义视图控制器中,您需要重写两个方法:
    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskAll;
    }
    

    【讨论】:

    • 你指的是哪些维度?框架 ?界限?
    • OMFG。你说的对。我指的是框架尺寸而不是边界。这就是为什么我得到错误的尺寸。但我不太确定那是什么?视图的波纹管 modalView 不是也在旋转吗?谢谢!
    猜你喜欢
    • 1970-01-01
    • 2017-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多