【发布时间】:2019-03-21 18:18:44
【问题描述】:
在我的主屏幕上有多个 UICollectionView 部分,所以我为每个部分(xib)使用了单独的 - 单独的视图(UICollectionViews)现在我必须执行导航(didSelectItemAt)我无法即使没有错误也执行它
我使用下面的导航代码(didSelectItemAt)
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let vc = UIStoryboard.init(name: "ProductListing", bundle: Bundle.main).instantiateViewController(withIdentifier: "ProductListingViewController") as? ProductListingViewController
(superview?.next as? ProductListingViewController)?.navigationController?.pushViewController(vc!, animated: true)}
【问题讨论】:
-
永远不要
(superview?.next as? ProductListingViewController)?。使用委托协议、闭包或通知(取决于您的用例)
标签: ios swift uiview uinavigationcontroller