Xcode:如何创建出现在另一个视图控制器中的PopUp视图控制器 [英] Xcode: How To Create A PopUp View Controller That Appears In Another View Controller

查看:137
本文介绍了Xcode:如何创建出现在另一个视图控制器中的PopUp视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想要弄清楚的是,我说有一个名为V1的视图控制器,里面有一个常规视图和一个按钮。现在,当您点击该按钮时,我希望该按钮创建一个动作,在同一个视图控制器V1中弹出另一个名为V2的视图控制器。

Basically what I am trying to figure out to do is, say I have one View Controller, called V1, that has a regular view inside it and a button. Now, when you tap that button, I want that button to create an action that pop-ups another View Controller, called V2, within the same view controller, V1.

V2的大小会减小一些,以至于它不会填满整个屏幕,但你仍然可以看到V2后面的第一层是V1。所以基本上,你永远不会离开V1。我希望这对我正在尝试做的事情有意义。我知道MTV应用程序具有这种功能。我正在谈论的图片如下: https://docs.google .com / leaf?id = 0BzlCAVXRsIPcNWUxODM2MDAtNDE3OS00ZTc4LTk5N2MtZDA3NjFlM2IzNmZk& hl = en_US

V2 will be reduced in size some so that it does not fill the entire screen, but you can still see the first layer which is V1 behind V2. So basically, you never really leave V1. I hope this makes sense for what I'm trying to do. I know the MTV app has this functionity. An image of what I'm talking about is here: https://docs.google.com/leaf?id=0BzlCAVXRsIPcNWUxODM2MDAtNDE3OS00ZTc4LTk5N2MtZDA3NjFlM2IzNmZk&hl=en_US

示例代码或示例也是我正在寻找的。

谢谢

推荐答案

您可以创建此类视图设置适当的属性类型 modalPresentationStyle 。请参阅下面的示例:

You can create such view by setting appropriate property type of modalPresentationStyle. See my example below:

UIViewController *V2 = [[UIViewController alloc] init];
V2.modalPresentationStyle = UIModalPresentationFormSheet;
V2.modalTransitionStyle = UIModalTransitionStyleCoverVertical;     
[V1 presentViewController:V2 animated:YES completion:nil];
V2.view.superview.frame = CGRectMake(0, 0, 540, 620); //it's important to do this after presentModalViewController
V2.view.superview.center = V1.view.center;
[V1 release];

这篇关于Xcode:如何创建出现在另一个视图控制器中的PopUp视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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