简体   繁体   English

使用选项UIModalPresentationOverCurrentContext减少以模态方式呈现的uiviewcontroller的帧大小

[英]Reducing the frame size of a uiviewcontroller being presented modally with option UIModalPresentationOverCurrentContext

I am recreating a popup style view controller. 我正在重新创建一个弹出式视图控制器。 In the implementation below I am instantiating a view controller and then presenting it on its parent VC modally using the option UIModalPresentationOverCurrentContext . 在下面的实现中,我实例化一个视图控制器,然后使用选项UIModalPresentationOverCurrentContext模态方式在其父VC上显示它。

I would like to reduce the frame size so as to make the new viewcontroller appear more like a popup but the frame size keeps getting overwritten. 我想减小帧大小,以使新的viewcontroller看起来更像弹出窗口,但帧大小不断被覆盖。 I also tried setting the frame size of the viewcontroller in its -viewWillAppear and -viewDidLoad methods but nothing changes. 我还尝试在其-viewWillAppear-viewDidLoad方法中设置viewcontroller的帧大小,但没有任何变化。 Any thoughts? 有什么想法吗?

UIStoryboard* popStoryboard = [UIStoryboard storyboardWithName:@"XXX" bundle:nil];
UIViewController* popViewController = [storyboard instantiateViewControllerWithIdentifier:@"XXXXXX"];

popViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
popViewController.view.frame = CGRectMake(0, 0, 400, 450);

[[self topMostViewController] presentViewController:popViewController animated: YES completion: nil];

您正在使用名为popViewController的指针变量实例化视图控制器,但您更改视图的框架并显示名为viewController的指针变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 确定是否以模态方式呈现UIViewController - Determining if a UIViewController is being presented modally 呈现的UIViewController模态显示移到顶部 - UIViewController presented modally show up shifted to the top 获取最高的 UIViewController(如果以模态方式呈现) - Get top most UIViewController if its presented modally 模态呈现的UIViewController在关闭时不会清空内存 - Modally presented UIViewController does not empty memory on close 以模态呈现的UIViewController的背景颜色随机变化 - Background Color Randomly Changes of UIViewController presented Modally 旋转呈现为UIModalPresentationOverCurrentContext的VC - Rotating a VC presented as UIModalPresentationOverCurrentContext 横向模式下的导航控制器堆栈,但模式呈现的视图控制器视图始终为纵向帧大小 - Navigation controller stack in landscape mode, but modally presented view controller view always in portrait frame size 在iOS7上模态显示时,以前的UIViewController会流血 - Previous UIViewController bleeds through when presented modally on iOS7 有没有办法知道UIViewController是否已经以模态方式呈现和解散? - Is there a way to know if a UIViewController has been presented and dismissed modally ? willRotateToInterfaceOrientation未在模态呈现的视图控制器中调用 - willRotateToInterfaceOrientation not being called in a modally presented view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM