iPad定制尺寸的模态视图控制器 [英] iPad custom size of modal view controller

查看:111
本文介绍了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的问题的解决方案是什么?唯一的解决方案是安排自定义模态视图控制器引擎?弹出窗口不符合我的设计要求:(

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天全站免登陆