一個視圖控制器用另一個視圖控制器的視圖取代它自己的視圖。這就是模態(modal)視圖。
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。這個就不一一贅述了。
關于模態視圖其實有個最重要的問題是:為什么稱為模態?還沒想明白。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。