I am trying to create a layout much like the iOS App Store. I have followed this tutorial: http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell/
Everything is working but the problem is that this tutorial does not cover tapping on a UICollectionView cell and segueing to a new UIViewController. Has anyone implemented that? I am new at Swift, so I need a little help. Thanks!
To do that you need to go to your ViewCollectionController and override the didSelectItemAtIndexPath method.
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let controller = self.storyboard?.instantiateViewControllerWithIdentifier("yourControllerIdHere") as UIViewController
presentViewController(controller, animated: true, completion: nil)
}
if you have a segue set up already then just do
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("yourSeguesIdentifier", sender: self)
}
So I actually got this functional. Probably not the most efficient, but like I said, Swift is not my wheelhouse. Anyway I just passed an instance of the UIViewController that contains the UITableView into the TableViewCell. Then I call performSegueWithIdentifier() like in Usernumbernine's answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.