【发布时间】:2017-05-05 10:23:11
【问题描述】:
我正在使用外部委托文件来处理 UICollectionView 的所有处理,并且我正在努力让集合视图单元格通过委托文件根据所选单元格执行转场。
这是我目前在委托文件中的内容:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell = collectionView.cellForItem(at: indexPath)
let mainController = MainController()
mainController.performSegue(withIdentifier: "detailSegue", sender: cell)
}
在我的主控制器上:
override func performSegue(withIdentifier identifier: String, sender: Any?) {
if identifier == "detailSegue" {
let detailController = DetailController()
self.present(detailController, animated: true)
}
}
我得到的错误:
Warning: Attempt to present <DetailController: 0x7fbed8e6e4b0> on <MainController: 0x7fbedda79830> whose view is not in the window hierarchy!
我想我可以通过委托调用引用,它会呈现控制器。
谢谢
【问题讨论】:
标签: ios swift delegates uicollectionview