2017-10-01 7 views
0

私はマスターテーブルビューから花の画像を表示するマスターディテールアプリを持っています。詳細ビューでより大きな画像を表示したいが、最後の画像を表示し続ける。クリックした画像の代わりに画像が最後に表示されます

DetailViewControllerは、MasterViewControllerの画像を最後の画像として表示しています。どんなMasterViewControllerにクリックされている、詳細に示す画像は、マスターからのリストの最後の画像..ですMasterViewController.swiftファイルで

override func viewDidLoad() { 
    super.viewDidLoad() 

    imageView1.image = MasterViewController.MyVariables.flowerImage!.first 

、ここにコードません:

override public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", 
              for: indexPath) 

    //cell.textLabel!.text = siteNames![indexPath.row] 

    switch (indexPath.section) { 
    case kRedSection: 
    do { cell.textLabel!.text = redFlowers[indexPath.row] 
     cell.detailTextLabel!.text = siteDetailRed![indexPath.row] 



     } 
    case kBlueSection: 
     do { 
     cell.textLabel!.text = blueFlowers[indexPath.row] 
     cell.detailTextLabel!.text = siteDetailBlue![indexPath.row] 

     } 
    default: 
     do { 
     cell.textLabel!.text = "Unknown" 
     cell.detailTextLabel!.text = "Unknown" 

     } 
    } 

    let test = UIImage(named: cell.textLabel!.text!)! 
    cell.imageView!.image = test 

    MyVariables.flowerImage = [test] 
    print("MyVariables.flowerImage", MyVariables.flowerImage) 


    return cell 
} 

答えて

0

私はこの機能にそれをデバッグしました。しかし、エラーメッセージの致命的なエラーが表示されています。このコード行でオプション値をアンラッピングしている間に予期せずnilが見つかりました。

関連する問題