一個視圖控制器用另一個視圖控制器的視圖取代它自己的視圖。這就是模態(modal)視圖。
10年積累的成都做網站、成都網站制作經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先網站設計后付款的網站建設流程,更有泗洪免費網站建設讓你可以放心的選擇與我們合作。
A modal view (that is, a view presented modally) provides self-contained functionality in the context of the current task or workflow.
明顯的,模態視圖打斷了當前的視圖堆棧,新生成了一個視圖,這個視圖當然也是有視圖控制器的,你可以這么使用模態視圖:
Use them to gather information from the user immediately.
Use them to present some content temporarily.
Use them to change work modes temporarily.
Use them to implement alternate interfaces for different device orientations.
Use them to present a new view hierarchy with a specific type of animated transition (or no transition).
任何視圖控制器都可以成為模態視圖控制器。模態視圖和普通視圖之間的差異:
還是有些小差異的。
模態視圖的兩個參數:
modalTransitionStyle
UIModalTransitionStyleCoverVertical
UIModalTransitionStyleFlipHorizontal
UIModalTransitionStyleCrossDissolve
UIModalTransitionStylePartialCurl
modalPresentationStyle
UIModalPresentationFullScreen
UIModalPresentationPageSheet
UIModalPresentationFormSheet
UIModalPresentationCurrentContext
這兩個參數是指過渡方式和最終的呈現方式。
模態視圖和顯示出它的視圖之間存在父子關系,一般都是通過父視圖來顯示和關閉:
presentModalViewController:controller animated:YES
dismissModalViewControllerAnimated:YES
模態視圖控制器和UIPopoverController的主要不同是用戶必須響應模態視圖。
模態對話框主要有UIAlertView, UIActionSheet, UILocalNotification。這個就不一一贅述了。
關于模態視圖其實有個最重要的問題是:為什么稱為模態?還沒想明白。