teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

コメントの消し忘れ

2017/04/21 06:29

投稿

退会済みユーザー
answer CHANGED
@@ -1,5 +1,4 @@
1
1
  ```Swift
2
- //Pushで遷移する場合
3
2
  let next = storyboard?.instantiateController(withIdentifier: "ViewController2")
4
3
  self.presentViewControllerAsModalWindow(next! as! NSViewController)
5
4
  ```

1

OSXアプリ

2017/04/21 06:29

投稿

退会済みユーザー
answer CHANGED
@@ -1,18 +1,5 @@
1
1
  ```Swift
2
2
  //Pushで遷移する場合
3
- let nextWindow = storyboard?.instantiateViewController(withIdentifier: "次のウィンドウのIdentifier")
3
+ let next = storyboard?.instantiateController(withIdentifier: "ViewController2")
4
- navigationController?.pushViewController(nextWindow!, animated: true)
4
+ self.presentViewControllerAsModalWindow(next! as! NSViewController)
5
-
6
- //Pushで遷移する場合(変数を渡したい時)
7
- let nextWindow = storyboard?.instantiateViewController(withIdentifier: "次のウィンドウのIdentifier") as! /* 次のウィンドウのクラス */
8
- /* ここで値を渡したり */
9
- navigationController?.pushViewController(nextWindow, animated: true)
10
- ```
5
+ ```
11
-
12
- ```Swift
13
- //Modalの場合
14
- let nextWindow = storyboard?.instantiateViewController(withIdentifier: "次のウィンドウのIdentifier")
15
- present(nextWindow!, animated: true, completion: nil)
16
- ```
17
-
18
- やりたいことはこれであっていますかね?