Main.storyboardの、あるViewControllerから、別のViewControllerに対してコントロール+ドラッグ&ドロップして「Show」を選択することでSegueを作成し、IdentifierをnextSegueに設定し、
swift
1import UIKit 2 3class ViewController: UIViewController { 4 5 @IBAction func buttonTapped(_ sender: Any) { 6 performSegue(withIdentifier: "nextSegue", sender: nil) 7 } 8 override func viewDidLoad() { 9 super.viewDidLoad() 10 // Do any additional setup after loading the view, typically from a nib. 11 12 performSegue(withIdentifier: "nextSegue", sender: nil) 13 } 14 15 override func didReceiveMemoryWarning() { 16 super.didReceiveMemoryWarning() 17 // Dispose of any resources that can be recreated. 18 } 19 20 21} 22
このようにボタンをAction接続し、その中でperformSegue(withIdentifier: "nextSegue", sender: nil)を実行することで画面遷移をすることができるのは分かるのですが、(ボタンが押されると画面が遷移する)
たとえばviwDidLoad()の中でperformSegue(withIdentifier: "nextSegue", sender: nil)を呼び出しても画面は遷移しません。
何故なのでしょうか?
swift
1func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { 2 if let image = info[UIImagePickerControllerOriginalImage] { 3 //現在のViewに表示 4 self.imageView.image = image as? UIImage 5 self.originalImage = image as? UIImage 6 7 //セグエの遷移 8 performSegue(withIdentifier: "nextSegue", sender: nil) 9 } 10 picker.dismiss(animated: true, completion: nil) 11 } 12
このように、imagePickerControllerでメディアの選択が終了した際に呼び出される関数内で画面の遷移を実装したいのですが、不可能なのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/27 08:16