【发布时间】:2016-03-31 02:57:50
【问题描述】:
所以现在我有一个rootViewController,它有一个UIPageViewController 作为其唯一的子视图,rootViewController 基本上是UIPageViewController 的包装类。现在我想从ViewControllerA(由rootViewController拥有)禁用UIPageViewController的滚动。
现在我已经为rootViewController 实现了一个委托方法(由ViewControllerA 创建),它告诉UIPageViewController 它必须根据ViewControllerA 提供的信息停止滚动。但要让ViewControllerA 能够调用由rootViewController 实现的委托方法,则需要rootViewController 是ViewControllerA 的实例变量。
这是最佳做法吗?使用NSNotificationCenter 会是更好的选择吗?还是这些方法都不是最佳选择?
【问题讨论】:
-
当您希望多个对象被告知正在发生的事情时,通常使用通知中心
标签: ios swift delegates uipageviewcontroller