1
2

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.

TabBarControllerをStoryboardReferenceを利用して導入してみた(Storyboardを分ける)

Last updated at Posted at 2019-12-15

状況

Youtubeチャンネルの素材用にTinderの模擬アプリを作成する際、
TabBarControllerを使ったのですが
やり方が色々あってこんがらがったのと、いくつかつまづいたのでメモ。

やりたいこと

TabBarControllerStoryboardReferenceを利用して導入する
->StoryboardをTabBarController, 遷移先のVC(Tabの数ぶんStoryboardを用意 or 遷移先を1つのStoryboardにまとめる)でそれぞれ分けたいのでStoryboardReferenceを利用
->遷移先のVCにNavigationControllerを継承させたい

対策

  • TabBarController.storyboardを新しく作る->TabBarControllerを新しく作って、つながっている2つのVCを消しておく
  • StoryboardReferenceをTabの数だけ作る
  • 各々のStoryboardReferenceをTabと紐付けたい遷移先のVCと紐付ける
  • TabBarControllerのis initial viewcontrollerにチェックを入れる
  • TARGETMain interfaceTabBarControllerが存在するstoryboardに設定
  • info.pistStoryboard NameTabBarControllerが存在するstoryboardに設定
  • 以上を行ってもTabが表示されない場合はcleanや再起動諸々を試す(info.plistとかをいじるとcleanとかで解決するパターンが結構あるらしい。僕自身もcleanして解決しました。)
    スクリーンショット 2019-12-16 0.07.06.png

※一番左のタブから順々に紐づいていく

- 遷移先のVCごとにStoryboardがある場合:
StoryboardReferenceを選択しShow the Attributes inspector->Storyboard reference->StoryboardStoryboardの名前(ファイル名)を入力(Storyboard IDではない)
- 遷移先のVCを1つのStoryboardにまとめている場合:
上記に加えて、VCをStoryboard IDから参照が必要->Show the Identity inspector->Identity->Storyboard IDに入力

  • control+右クリックで各々のStoryboardReferenceに繋ぐ->Relationship Segueview controllersを選択
    (※Modalなどではない)
  • 遷移先のVCでIs Initial Viewcontrollerの設定を確認(NCが紐づいているならそちらに設定する)
  • 遷移先のVCでIs Initial Viewcontrollerに設定したものにTabBar Itemを挿入

以上。

参考

[Xcode7] 「Unknown class xxxxx in Interface Builder file.」が出る - Qiita

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?