別のビューコントローラに渡す情報を取得しようとしています。私はセグーを行い、何も表示されていません。私は情報を整理するために外部クラスを使用しています。しかし、なぜそれが機能していないのか分かりません。スウィフト、通過した情報が表示されない
最初のビューコントローラ:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "toLocationVC" {
let lVC = segue.destinationViewController as! LocationViewController
lVC.locationImage?.image = locations[locationSelection].image;
lVC.nameLabel?.text = locations[locationSelection].name;
lVC.descriptionTextView?.text = locations[locationSelection].desc;
}
第2のビュー:
var selectedLocation : Location?;
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
locationImage.image = selectedLocation!.image
nameLabel.text = selectedLocation!.name
descriptionTextView.text = selectedLocation!.desc
}
、これはクラス場所である:私の周りのコードの一部を変更しようとした
class Location {
var image : UIImage
var name : String
private var description : String
var desc : String {
return description + "\n\n\nThis Description and Images Provided by http://www.travel.usnews.com"
}
init(name : String, image : UIImage, description: String) {
self.name = name;
self.image = image;
self.description = description;
}
}
、何も動作していないようです。
なぜコードを 'didReceiveMemoryWarning'の中に入れますか? – Christian
オハイオ州私の悪い、私はここでそれを間違って書いた..内部はviewdidload – art3mis
それは動作しません..それは最初のビューからの情報が渡されていないようです – art3mis