2017-05-14 5 views
0

したがって、最初のページから2ページ目に画像を移動しようとしています。しかし、私の準備()メソッドが動作していないと私は理由を知らない。 準備関数の前にオーバーライドを入れようとしましたが、関数が何もオーバーライドしていないと言います。私のprepareForSegue()メソッドが機能していません

import UIKit 

class BeginningPage: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { 

@IBOutlet weak var ImageView: UIImageView! 

override func viewDidLoad() { 
    super.viewDidLoad() 

    // Do any additional setup after loading the view. 
} 

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { 
    // Dismiss the picker if the user canceled. 
    dismiss(animated: true, completion: nil) 
} 

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { 

    // The info dictionary may contain multiple representations of the image. You want to use the original. 
    guard let selectedImage = info[UIImagePickerControllerOriginalImage] as? UIImage else { 
     fatalError("Expected a dictionary containing an image, but was provided the following: \(info)") 
    } 

    // Set photoImageView to display the selected image. 
    ImageView.image = selectedImage 

    // Dismiss the picker. 
    dismiss(animated: true, completion: nil) 
} 

//MARK: Action 

@IBAction func PressImage(_ sender: UITapGestureRecognizer) { 
    let imagePickerController = UIImagePickerController() 
    imagePickerController.sourceType = .photoLibrary 
    imagePickerController.delegate = self 
    present(imagePickerController, animated: true, completion: nil) 

} 

func prepare(segue: UIStoryboardSegue, sender: AnyObject?) { 
    if segue.identifier == "mySegue" { 
    if let destination = segue.destination as? ViewController { 
     destination.text = "123" 
     destination.image = ImageView.image 
     destination.LayerImage.image = ImageView.image 
     } 
     } 
    } 
} 
+0

識別子..? –

答えて

2

あなたの名前は間違っています。正しいバージョンin docsを確認してください。メソッドの定義は次のようになります。

スウィフト3:

override func prepare(for segue: UIStoryboardSegue, sender: Any?)

スウィフト2:あなたはVCからあなたのセグエを接続し、与えるべきである

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)

関連する問題