我想根据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 ")
}
}
根据Collection View中的选择,它应该转换为不同的UiCollectionView控制器
Tried this command
self.performSegue(withIdentifier:“Selection1”,sender:self)
但它错了: 'NSInternalInconsistencyException',原因:'无法使类型的视图出列:具有标识符ProductCell的UICollectionElementKindCell - 必须为标识符注册一个nib或类或在故事板中连接原型单元'
执行此类Segue的最佳方式是什么? 请指教
由于
答案 0 :(得分: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 ")
}
}