2017-07-15 9 views
0

私は4つのセルを持ち、それぞれに1つのラベルがあります。セグメンテーションを実行し、データを送信する条件がある場合

enter image description here

ユーザーがセルをクリックするたびに、それは別のビューにそれらを取るだろうし、そのビューに私は、セルのラベルのように命名されるべき最上位ラベルを持っています。私は、しかし、タイトルラベルの値を渡すセグエの準備に使用

enter image description here

:私はセル001をクリックした場合それでは、次のページのタイトルラベルは、タイトルラベルを表示するには、以下の001の画像でなければなりません私はコードを書くことができますどのように言うこと:

if cell label = 001 { 
    newViewTitle.text = cell label 
} 

これは私の現在のセグエコードの準備:

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

    if let destination = segue.destination as? VolumeImgVC { 


     if let VolumeNumLbl = volumEDnum as? String! { 
      destination.Vtitle = VolumeNumLbl 
     } 
     if let VolumeNumLbl = volumEDnum1 as? String! { 
      destination.Vtitle = VolumeNumLbl 
     } 
     if let VolumeNumLbl = volumEDnum2 as? String! { 
      destination.Vtitle = VolumeNumLbl 
     } 

    } 
} 

上記のコードは動作しませんし、ONL最後のif let文を実行します。

お願いします。

+0

データを渡すセルのクリックでcellnamelabel配列の配列を作成いただきありがとうございますか! –

答えて

1

は、あなたが次のビューコントローラに現在のセルのデータを渡したいだけindexPathを選択し取得するtableView.indexPathForSelectedRowプロパティを使用して

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
     if segue.identifier == "detailSeque" { 
      if let destination = segue.destination as? VolumeImgVC { 
      if let indexPath = self.tableView.indexPathForSelectedRow { 
       let volumeNum = volumeNumLblArray[indexPath.row] 
       destination.Vtitle = volumeNum 
      } 
      } 
     } 
    } 
+0

セルのクリックでセル名ラベル配列を作成するとどういう意味ですか?どのように、どこでそれを行うのですか? @suhit –

+0

はhttp://www.codingexplorer.com/segue-uitableviewcell-taps-swift/を参照してください – suhit

関連する問題