您的位置:首页 > 其它

模态视图的概念以及显示、变换方式介绍

2014-05-29 09:57 369 查看
学几个单词

dissolve [dɪ'zɒlv] vi.溶解;解散
curl [kɜːl] vi.
卷曲

什么是模态视图?

比如UIAlertView,它就是一个模态视图。对于模态视图和普通视图最主要的区别就是模态视图显示的时候不能对其他视图进行操作。主要用来收集或显示一些信息。

思考:弹出警告框的时候,背景视图变暗不能操作,所以说警告框就是一个模态视图。

PresentationStyle(显示方式)

对于iPhone来讲PresentationStyle始终是UIModalPresentationFullScreen模式显示ModelViewController

对于iPad有四种显示方式,如下所示(默认全屏)

typedefenum {

UIModalPresentationFullScreen = 0,

UIModalPresentationPageSheet,

UIModalPresentationFormSheet,

UIModalPresentationCurrentContext,

} UIModalPresentationStyle;

UIModelPresentationFullScreen弹出VC时,被弹出的视图(presentedVC)充满全屏
UIModalPresentationPageSheet弹出VC时,presentedVC的height、width和presenting
VC相同,竖屏时和UIModelPresentationFullScreen相同,横屏时未覆盖区域变暗并阻止用户点击
UIModelPresentationFromSheet弹出VC时,presentedVC的height、width均会小于presentingVC,且presented居中显示,四周变暗
UIModalPresentationCurrentContext弹出VC时,和presentedVC的弹出方式相同

TransitionStyle(变换效果)

默认的presented方式是CoverVertical(竖直覆盖),也可以设置水平翻转、交叉溶解、翻页等效果

typedefenum {

UIModalTransitionStyleCoverVertical = 0,

UIModalTransitionStyleFlipHorizontal,

UIModalTransitionStyleCrossDissolve,

UIModalTransitionStylePartialCurl,

} UIModalTransitionStyle;

Delegate & Dismiss
ModalViewController

dismissViewControllerAnimated:completion,对于这个方法的调用者最简单的是[selfdismissViewControllerAnimated:completion],如果presentedVC和presenting
VC之间有数据传递的话,建议在presentedVC中使用代理方法dissmiss掉presented
VC
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐