2016-09-21 5 views
0

私はこのprepareForSegue機能が含まれているテーブルビューを持っている:テーブルビューととボタン(クラッシュ)

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    let upcoming: CategoryDeviceViewController = segue.destination as! CategoryDeviceViewController 
    let myindexpath = self.MainPageTableView.indexPathForSelectedRow 
    let titleString = self.CategoryTitle.object(at: ((myindexpath as NSIndexPath?)?.row)!) as? String 
    upcoming.titlestring = titleString 
    self.MainPageTableView.deselectRow(at: myindexpath!, animated: true) 
} 

6個の細胞からタイトルを取得し、nvigationalバーのタイトルの次のビューにそれらを保存します。

セグ機能の準備が入っているこのビューには、別の(3番目の)ビューコントローラに移動するナビゲーションバーのボタンがあります。

私はそのボタンをクリックするたびに

このライン上のアプリのクラッシュ:

let upcoming: CategoryDeviceViewController = segue.destination as! CategoryDeviceViewController 

私は、エラーの理由を知っているが、私はそれをどのように解決することができますか?

+0

あなたが知っているエラーの原因は何ですか?あなたの墜落についてログには何が書かれていますか? – Santosh

+0

今度はCategoryDe​​viceViewControllerにする必要がありますが、ボタンをクリックすると3番目のビューコントローラが開きます – Mariah

+0

この 'segue'のために' destination'viewControllerをあなたのストーリーボードに適切に設定しましたか? – Santosh

答えて

1

あなたのセグとクラッシュログごとに、ここにあなたがいなくなっていると思います。あなたのセグの識別子で目的地を特定してみてください:

func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    if segue.identifier == "ShowCategoryDevice" { 
     let upcoming: CategoryDeviceViewController = segue.destination as! CategoryDeviceViewController 
     let myindexpath = self.MainPageTableView.indexPathForSelectedRow 
     let titleString = self.CategoryTitle.object(at: ((myindexpath as NSIndexPath?)?.row)!) as? String 
     upcoming.titlestring = titleString 
     self.MainPageTableView.deselectRow(at: myindexpath!, animated: true) 

    }else { 
     let upcoming: PopOverViewController = segue.destination as! PopOverViewController 
     //do rest of your stuff 
    } 
} 
+0

この質問で私を助けることができます:http://stackoverflow.com/questions/39619860/getting-the-values-of-data-stored-in-firebase/39620712#39620712 – Mariah

関連する問題