模态视图控制器的 iPad 自定义大小 [英] iPad custom size of modal view controller

查看:21
本文介绍了模态视图控制器的 iPad 自定义大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个特定大小的模态视图控制器.我试图避免使用自定义视图(在当前视图上创建全屏黑色半透明覆盖,在该视图上添加模态视图,执行动画等)来呈现它,因为没有适合我的尺寸的 modalPresentationStyle控制器.

I have a couple of modal view controllers of certain size. I'm trying to avoid the use of custom views (creating full screen black translucent overlay over current view, add the modal view over that view, do the animations, etc) to present it because there is no modalPresentationStyle that fits the size of my controllers.

现在我正在使用 UIModalPresentationPageSheet 但我的视图高度较小,而且我有一个丑陋的空白区域

Now I'm using UIModalPresentationPageSheet but my view is smaller in height and I have an ugly blank space

想要的演示

 _______________
|    _______    |
|   |       |   |
|   |  MyVC |   |
|   |       |   |
|    -------    |
 --------------- 

实际演示

 _______________
|   |       |   |
|   |  MyVC |   |
|   |       |   |
|   |-------|   |
|   | blank |   |
 ---------------    

如果我使用 UIModalPresentationFormSheet,容器的宽度会更小.

If I use the UIModalPresentationFormSheet the container is smaller in width.

我正在尝试弄清楚如何做到这一点,但我不知道是否可行.呈现比任何presentationStyles都小的模态VC的问题的解决方案是什么?唯一的解决办法是安排一个自定义模态视图控制器引擎"?Popovers 不符合我的设计要求:(

I'm trying to figure out how to do it but I don't know if it's possible. What is the solution to the problem of presenting a modal VC smaller than any of the presentationStyles? The only solution is to arrange a "custom modal view controller engine"? Popovers doesn't fit my design requirements :(

推荐答案

作为这里的其他一些用户,我也遇到了模态视图控制器的来源不正确的问题.经过一些实验,我找到了一个对我有用的解决方案:

As some other users here, I also had the problem that the origin of the modal view controller was not correct. After some experiments, I found a solution that worked for me:

- (void)viewWillLayoutSubviews{
    [super viewWillLayoutSubviews];   
    self.view.superview.bounds = CGRectMake(0, 0, <width>, <height>);
}

这篇关于模态视图控制器的 iPad 自定义大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆