Fork me on GitHub

Modal View Controller的不同呈现类型

ModalViewController可以有不同的呈现类型(modalPresentationStyle),在ipad下要提供多方向支持时,就要注意可能要改变ModalViewController的呈现方式,列举如下:
1. UIModalPresentationFullScreen:全屏模式,即弹出窗口占满整个屏幕,在portrait模式和landscape模式下都一样。
2. UIModalPresentationFormSheet:会将窗口缩小,使之居于屏幕中间,在portrait和landscape下都一样,但要注意landscape下如果软键盘出现,窗口位置会调整。
3. UIModalPresentationPageSheet:比较给力的一种模式,在portrait时是FullScreen,在landscape时和FormSheet模式一样,注意有这种需求的朋友直接用这种模式就可以了,不要想着自己编程去在FullScreen和FormSheet去切换,很麻烦
4. UIModalPresentationCurrentContext:(有空再补充)
例子:弹出UITableViewController:

 

实现:在类ConfigViewController中弹出类ConfigMenuController :UITableViewController

 

如下:

在类ConfigViewController对应的方法中实现

ConfigMenuController *cmc = [[[ConfigMenuController alloc] initWithNibName:nil bundle:nil] autorelease];

 

cmc.modalPresentationStyle = UIModalPresentationFormSheet;

[self presentModalViewController: cmc animated: YES];

posted on 2012-05-15 19:29  pengyingh  阅读(585)  评论(0编辑  收藏  举报

导航