转自:http://blog.csdn.net/wudizhukk/article/details/8553554函数
-(void)buttonDown:(id)sender{动画
ViewTwo *two = [[ViewTwo alloc]init];url
two.delegate = self;spa
two.modalPresentationStyle=UIModalPresentationFullScreen;.net
two.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;//弹出时的动画风格 对弹出目标页面设置代理
[self presentModalViewController:two animated:YES];code
}orm
以上是代码实例 下面是网上抄来无聊时看看的,补充补充的blog
1、主要用途ip
弹出模态ViewController是IOS变成中颇有用的一个技术,UIKit提供的一些专门用于模态显示的ViewController,如UIImagePickerController等。弹出模态ViewController主要使用于一下这几种情形:
一、收集用户输入信息
二、临时呈现一些内容
三、临时改变工做模式
四、相应设备方向变化(用于针对不一样方向分别是想两个ViewController的状况)
五、显示一个新的view层级
这几种情形都会暂时中断程序正常的执行流程,主要做用是收集或者显示一些信息。
2、几个概念和经常使用设置
一、presenting view controller Vs presented view controller
当咱们在view controller A中模态显示view controller B的时候,A就充当presenting view controller(弹出VC),而B就是presented view controller(被弹出VC)。官方文档建议这二者之间经过delegate实现交互,若是使用过UIImagePickerController从系统相册选取照片或者拍照,咱们能够发现imagePickerController和弹出它的VC之间就是经过UIImagePickerControllerDelegate实现交互的。所以咱们在实际应用用,最好也遵照这个原则,在被弹出的VC中定义delegate,而后在弹出VC中实现该代理,这样就能够比较方便的实现二者之间的交互。
二、Modal Presentation Styles(弹出风格)
经过设置presenting VC的modalPresentationStyle属性,咱们能够设置弹出View Controller时的风格,有如下四种风格,其定义以下:
typedef enum { UIModalPresentationFullScreen = 0, UIModalPresentationPageSheet, UIModalPresentationFormSheet, UIModalPresentationCurrentContext, } UIModalPresentationStyle;
UIModalPresentationFullScreen表明弹出VC时,presented VC充满全屏,若是弹出VC的wantsFullScreenLayout设置为YES的,则会填充到状态栏下边,不然不会填充到状态栏之下。
UIModalPresentationPageSheet表明弹出是弹出VC时,presented VC的高度和当前屏幕高度相同,宽度和竖屏模式下屏幕宽度相同,剩余未覆盖区域将会变暗并阻止用户点击,这种弹出模式下,竖屏时跟UIModalPresentationFullScreen的效果同样,横屏时候两边则会留下变暗的区域。
UIModalPresentationFormSheet这种模式下,presented VC的高度和宽度均会小于屏幕尺寸,presented VC居中显示,四周留下变暗区域。
UIModalPresentationCurrentContext这种模式下,presented VC的弹出方式和presenting VC的父VC的方式相同。
这四种方式在iPad上面通通有效,但在iPhone和iPod touch上面系统始终已UIModalPresentationFullScreen模式显示presented VC。
三、Modal Transition Style(弹出时的动画风格)
经过设置设置presenting VC的modalTransitionStyle属性,咱们能够设置弹出presented VC时场景切换动画的风格,其定义以下:
typedef enum { UIModalTransitionStyleCoverVertical = 0, UIModalTransitionStyleFlipHorizontal, UIModalTransitionStyleCrossDissolve, UIModalTransitionStylePartialCurl, } UIModalTransitionStyle;
咱们能够看到有从底部滑入,水平翻转进入,交叉溶解以及翻页这四种风格可选。这四种风格在不受设备的限制,即无论是iPhone仍是iPad都会根据咱们指定的风格显示转场效果。
四、Dismiss Modal ViewController(消失弹出的VC)
消失presented VC,咱们能够经过调用如下两个函数中的任何一个来完成
dismissModalViewControllerAnimated: // 将要废弃,不同意继续使用 dismissViewControllerAnimated:completion: