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 } }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。