我应该继承 UIPageViewController 吗?
Should I subclass UIPageViewController?
使用 UIPageViewController 的首选方式是什么?
继承 UIPageViewController 并将该对象用作其自身的数据源?
创建容器 VC 并添加 UIPageViewController 作为它的子容器 VC? (以容器 VC 作为数据源)
Pros/Cons 我们将不胜感激。
首选方法 #2。如果你使用#1,你可能 运行 变成 this layout issue。此外,UIPageViewController
有许多 readonly
属性,使用组合而不是继承将鼓励您按照设计的方式使用它。
您不需要创建父视图控制器来实现委托方法。
您只需在场景浏览器中拖动一个 NSObject 并将其 class 设置为您的 datasource/delegate 对象。
使用 UIPageViewController 的首选方式是什么?
继承 UIPageViewController 并将该对象用作其自身的数据源?
创建容器 VC 并添加 UIPageViewController 作为它的子容器 VC? (以容器 VC 作为数据源)
Pros/Cons 我们将不胜感激。
首选方法 #2。如果你使用#1,你可能 运行 变成 this layout issue。此外,UIPageViewController
有许多 readonly
属性,使用组合而不是继承将鼓励您按照设计的方式使用它。
您不需要创建父视图控制器来实现委托方法。
您只需在场景浏览器中拖动一个 NSObject 并将其 class 设置为您的 datasource/delegate 对象。