[英]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.