2017-04-10 56 views
-1

enter image description here執行SEGUE到不同的控制器我想原因請看基於選擇在UICollectionView不同的控制器:如何UICollectionVIew

覆蓋FUNC的CollectionView(_的CollectionView:UICollectionView,didSelectItemAt indexPath:IndexPath){

if indexPath.item == 0 && indexPath.section == 0 { 

    print ("Item 0 and section 0 selected") 

     Perform Segue to Controller1 


    } else if (indexPath.item == 1 && indexPath.section == 0){ 

     ----> Perform Segue to Controller 2 


     print ("Item 1 and section 0 selected") 
    } else { 
     print("Not selected ") 
    } 



} 

在種質庫的選擇看,應該原因請看不同UiCollectionView控制器

Tried this command 

self.performSegue(withIdentifier:「選擇1」,發件人:個體經營)

但它出錯了: 「NSInternalInconsistencyException」,理由是:「不能出列類型的視圖:UICollectionElementKindCell與標識符ProductCell - 必須註冊一個筆尖或一個類的標識符或連接故事板中的原型單元格'

執行此類Segue的最佳方法是什麼? 請告知

感謝

+0

嗯......'performSegueWithIdentifier:sender:'? – crizzis

+0

可能重複[IOS - 如何使用Swift以編程方式進行分析](http://stackoverflow.com/questions/27604192/ios-how-to-segue-programmatically-using-swift) –

+0

嗨,我嘗試使用給定的選項在上面的鏈接,但我得到了這個錯誤,'NSInternalInconsistencyException',原因:'無法出隊類型的視圖:帶標識符ProductCell的UICollectionElementKindCell - 必須註冊標識符的一個筆尖或類或連接故事板中的原型單元格' –

回答

0

覆蓋FUNC的CollectionView(_的CollectionView:UICollectionView,didSelectItemAt indexPath:IndexPath){

if indexPath.item == 0 && indexPath.section == 0 { 




     self.performSegue(withIdentifier: "Selection1", sender: self) 







    } else if (indexPath.item == 1 && indexPath.section == 0){ 


    self.performSegue(withIdentifier: "Selection2", sender: self) 

     print ("Item 1 and section 0 selected") 
    } else { 
     print("Not selected ") 
    } 



} 
爲了

也擺脫錯誤的,我不得不更新集合標識符可重複使用的視圖enter image description here