因此,現在我有一個rootViewController
,其UIPageViewController
作爲其唯一子視圖,rootViewController
基本上是UIPageViewController
的包裝類。現在我想從ViewControllerA
(rootViewController
擁有)關閉UIPageViewController
的滾動。我是否應該使用委託方法或UINotificationCenter
現在我已經實現了rootViewController
委託法(ViewControllerA
創建),告訴它有UIPageViewController
取決於由ViewControllerA
提供的信息來停止滾動。但是,要使ViewControllerA
能夠調用由rootViewController
實現的委託方法,則需要將rootViewController
作爲ViewControllerA
的實例變量。
這是最佳做法嗎?會使用NSNotificationCenter
是更好的選擇嗎?或者,這些方法都不是最佳選擇?
當你想讓多個對象知道發生了什麼時,通常會使用通知中心 – Andrea