I have UIButton inside UICollectionViewCell which is inside UITableViewCell, I need to navigate another UIViewController on tapping that UIButton. But UINavigationController is not working inside the UICollectionViewCell. Can anybody please help?
I do not find any navigationController in my code.
import UIKitclass TrendingProductTVCell: UITableViewCell {
@IBOutlet weak var trendingProductCV: UICollectionView! override func awakeFromNib() { super.awakeFromNib() trendingProductCV.delegate = self trendingProductCV.dataSource = self }
}
extension TrendingProductTVCell: UICollectionViewDataSource, UICollectionViewDelegate {
func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = trendingProductCV.dequeueReusableCell(withReuseIdentifier: "TrendingProductsCVCell", for: indexPath) as? TrendingProductsCVCell cell?.trendingAddToCartBtn.addTarget(self, action: #selector(addToCartBtnTapped), for: .touchUpInside) return cell! } @objc func addToCartBtnTapped(sender: UIButton){ let productDetail = trendingProductsDataArray[sender.tag] }
}
#ios #swift