摘要:
有同學在 CocoaChina 上提出這樣一個問題:A viewController 中包含一個 B viewController(B 的 view 作為 A 的 view 的 subView),在橫豎屏轉換時,A 可以得到屏幕旋轉相關的消息(如:shouldAutorotateToInterfaceOrientation),而 B 卻得不到,即使 A,B 都實現了這些函數。原貼見這里:http://www.cocoachina.com/bbs/read.php?tid=40973&page=1#393765
這個問題我以前也碰到過,稍微研究了一下,其原因是 A 是在 AppDelegate 里 window 的 controller 層次體系中(比如,是 navigation push進去的等等),而 B 只是創建出來,讓 A 方便使用其 view 而已,B 并沒有加入這個層次體系中( B 的 parentViewController 為 nil,哪怕 B.view.superview 是 A.view)。所以 A 會跟著那個層次體系得到系統旋轉相關的消息,而 B 被涼在一邊,
閱讀全文