質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

iPhone

iPhoneとは、アップル社が開発・販売しているスマートフォンです。 同社のデジタルオーディオプレーヤーiPodの機能、電話機能、インターネットやメールなどのWeb通信機能の3つをドッキングした機器です。

Swift 2

Swift 2は、Apple社が独自に開発を行っている言語「Swift」のアップグレード版です。iOSやOS X、さらにLinuxにも対応可能です。また、throws-catchベースのエラーハンドリングが追加されています。

Q&A

1回答

1338閲覧

TabBarControllerのナビゲーションボタンから遷移方法

Yoshi66

総合スコア8

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

iPhone

iPhoneとは、アップル社が開発・販売しているスマートフォンです。 同社のデジタルオーディオプレーヤーiPodの機能、電話機能、インターネットやメールなどのWeb通信機能の3つをドッキングした機器です。

Swift 2

Swift 2は、Apple社が独自に開発を行っている言語「Swift」のアップグレード版です。iOSやOS X、さらにLinuxにも対応可能です。また、throws-catchベースのエラーハンドリングが追加されています。

0グッド

0クリップ

投稿2016/12/31 06:05

TabBarControllerにナビゲーションバーを付けたかったので、タブの先のViewController全てを下記のBaseViewControllerから引き継がせました。

import UIKit class BaseViewController: UIViewController { override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } override func viewDidLoad() { super.viewDidLoad() // set title self.navigationItem.title = "title" // nav right item button let settingBtn:UIButton = UIButton(type: UIButtonType.System) settingBtn.tintColor = UIColor.blueColor() settingBtn.setTitle("グループを作る", forState: UIControlState.Normal) settingBtn.addTarget(self, action: "onClickSetting", forControlEvents: UIControlEvents.TouchUpInside) settingBtn.frame = CGRectMake(0, 0, 24, 24) self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: settingBtn) } func onClickSetting() { let FriendsTableVC = FriendsTableViewController() let modalView = UINavigationController(rootViewController: FriendsTableVC) modalView.modalTransitionStyle = UIModalTransitionStyle.CoverVertical self.presentViewController(modalView, animated: true, completion: nil) } }

このBaseViewControllerのナビゲーションボタンから他のTableViewControllerに遷移させたいのですが、させた先のCellのIdentifierが上手く読み取られません。

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier FriendList - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

イメージ説明

###質問項目
1・BaseViewControllerをStoryBoardのどこに含めるべきなのか(そもそもStoryBoardに置くべきなのか)

2・BaseViewControllerを継承したコントローラーからTableViewControllerに遷移させるにはどうすればいいのか

class FriendsTableViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() } override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 1 } override func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = self.tableView.dequeueReusableCellWithIdentifier("FriendList", forIndexPath: indexPath) print(cell) return cell } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

キャスト入れてみてどうなりますか

swift

1 let cell = self.tableView.dequeueReusableCellWithIdentifier("FriendList", forIndexPath: indexPath) as! カスタムセルクラス

投稿2016/12/31 11:24

fromageblanc

総合スコア2724

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問