2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Xcode初期プロジェクトファイル Page-Based Application

Last updated at Posted at 2016-08-26

UIPageViewControllerを実装しなければいけなくなったので、参考になりそうと思って見てみました。

RootViewController

pageViewControllerを宣言、自身のSubViewとして追加

  • pageViewControllerを宣言
  • 最初のViewController startingViewController を宣言
  • setViewControllersする
    • セットするのは配列なので一見するとスワイプで見せる予定のViewControllerを全て突っ込みたくなるが、最初のViewControllerしか入れないようにする。
  • pageViewControlleraddChildViewControllerする
  • pageViewController.viewviewaddSubviewする

DataViewController

実際に表示されるビューとなる

  • dataLabel
  • dataObject

ModelController

UIPageViewControllerDataSourceの実装
(UIPageViewControllerDataSourceについてはこちら)

33行目のviewControllerAtIndexは下から呼ばれてるだけ

  • viewControllerBeforeViewController
  • viewControllerAfterViewController

Storyboard

DataViewControllerにセグエは何も生やさない
実務でも(おそらく)PageViewControllerが表示する予定のViewController(今回の場合はRootViewController)までつながってれば:ok:

PageViewControllerには何のセグエも生えないので若干腑に落ちない感じがあった。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?