2017-01-01 11 views
-1

Thisは私のコレクションビューです。別のビューコントローラにセグをするためには、それぞれのイメージが必要です。この機能を構築する最も簡単な方法は何ですか?コレクションビューから複数の異なるビューコントローラに分割する最も効果的な方法は何ですか?

+0

は、クエリを尋ねる前にhttp://stackoverflow.com/help/how-to-askを参照してください。 – Prasad

答えて

0

あなたは、特定のViewControllerのためにナビゲーションする前に、複数のビューのセグエ接続の識別子を確認することができます: -

let showAddressSegueIdentifier = "gotoAddressdetails" 
    let showNameSegueIdentifier = "gotoNamedetails" 

     //MARK: - Navigation 
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
       //Verify segue identifier 
       if segue.identifier == showNameSegueIdentifier { 
        if let indexPath = collectionView?.indexPath(for: sender as! UICollectionViewCell) { 
         let controller = segue.destination as! FirstViewController 
         let data = details[indexPath.item] 
         controller.name = data["name"] as? String ?? "" 
        } 
       }else if segue.identifier == showAddressSegueIdentifier { 
        if let indexPath = collectionView?.indexPath(for: sender as! UICollectionViewCell) { 
         let controller = segue.destination as! SecondViewController 
         let data = details[indexPath.item] 
         controller.address = data["address"] as? String ?? "" 
        } 
       } 
      } 
関連する問題