(2)の”押下した画面に遷移する"はどのようにすれば良いのでしょうか?
- 画面1からメニューボタンを押下
- メニュー画面を開く
- メニューから画面2を押下
- メニューを閉じる
- 画面2に遷移する
コード
以下のようにやってみたのですがうまく画面遷移できませんでした...
// 1. 画面1からメニューボタンを押下 @IBAction func showMenu(sender: UIBarButtonItem) { let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) let destVC = storyboard.instantiateViewControllerWithIdentifier("メニュー画面のID") // メニュー画面を開く self.presentViewController(destVC, animated: true, completion: nil) }
// 2. メニューから画面2を押下 @IBAction func moveToContent(button: UIButton) { // メニューを閉じる self.dismissViewControllerAnimated(true, completion: nil) // 画面2に遷移する let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) let destVC = storyboard.instantiateViewControllerWithIdentifier("画面2のID") self.parentViewController!.presentViewController(destVC, animated: false, completion: nil) }
画面構成
画面1
- UINavigationController
- UIViewController
画面2
- UINavigationController
- UIViewController
メニュー画面
- UINavigationController
- UIViewController
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。