いつもお世話になります。
現在、日記アプリを作っています。
日記編集画面からUINavigationController、timelaneViewControllerにつながった日記詳細画面に画面遷移するため、
以下のようにコードを書きました。
swift
1//ノート詳細画面へ飛ぶ 2 let timeLine = self.storyboard?.instantiateViewControllerWithIdentifier("timeLine") 3 let noteDetail = self.storyboard?.instantiateViewControllerWithIdentifier("noteDetail") 4 let navigation:UINavigationController = self.storyboard?.instantiateViewControllerWithIdentifier("timeLineNavi") as! UINavigationController 5 navigation.viewControllers = [timeLine!,noteDetail!] 6 self.presentViewController(navigation, animated: true, completion: nil) 7
結果、画面遷移はうまくいくのですが、タイムラインと日記詳細画面のタブバーが表示されません。
どのようにすれば、タブバーが表示する状態で画面遷移できますでしょうか。よろしくお願いします。
補足
質問がわかりにくくすみません!実現したい画面遷移はNoteViewController(写真二枚目)から日記詳細画面です。
教えていただいたサイトを参考に、コードを書いてみました。
NoteViewController.swift
//日記詳細画面へ飛ぶ let tabbar = self.storyboard?.instantiateViewControllerWithIdentifier("tabbar")as! TabBarController //1番目のタブのviewcontrollerを取得 let vc:UINavigationController = tabbar.viewControllers![0] as! UINavigationController //一番目のタブを選択状態にする tabbar.selectedViewController = vc let timeline = self.storyboard?.instantiateViewControllerWithIdentifier("timeLine") let noteDetail = self.storyboard?.instantiateViewControllerWithIdentifier("noteDetail") vc.viewControllers = [timeline!,noteDetail!] vc.popToRootViewControllerAnimated(false) vc.viewControllers[0].performSegueWithIdentifier("toNoteDetail", sender: nil)
結果:画面遷移せず、エラーで落ちることもない。
メッセージ:
Unbalanced calls to begin/end appearance transitions for <し_ふ_んノート.NoteDetailViewController: 0x16a4bb00>.
//日記詳細画面へ飛ぶ let tabbar = self.storyboard?.instantiateViewControllerWithIdentifier("tabbar")as! TabBarController //1番目のタブのviewcontrollerを取得 let vc:UINavigationController = tabbar.viewControllers![0] as! UINavigationController //一番目のタブを選択状態にする tabbar.selectedViewController = vc let timeline = self.storyboard?.instantiateViewControllerWithIdentifier("timeLine") let noteDetail = self.storyboard?.instantiateViewControllerWithIdentifier("noteDetail") vc.viewControllers = [timeline!,noteDetail!] self.presentViewController(vc, animated: true, completion: nil)
結果:エラー
メッセージ
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <し_ふ_んノート.NoteViewController: 0x15fe2b80>.'
となってしまいます。
修正点などを教えていただけたら幸いです。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/01/03 14:53
2016/01/04 04:16
2016/01/04 06:52
2016/01/05 01:09