问题是这样的线回零:UICollectionView prepareForSegue indexPathForCell为零的iOS 9
if let indexPath = self.collectionView?.indexPathForCell(sender as! UICollectionViewCell)
出于这个原因,我不能传递任何信息,该标识符被设置,该委托被设置。
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "DetalleSegueIdentifier" {
if let indexPath = self.collectionView?.indexPathForCell(sender as! UICollectionViewCell) {
let detailVC = segue.destinationViewController as! DetalleNoticiaViewController
detailVC.contact = self.noticia[indexPath.row]
}
}
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
self.performSegueWithIdentifier("DetalleSegueIdentifier", sender: collectionView.cellForItemAtIndexPath(indexPath))
}
任何帮助?
你在哪里打电话给你的segue?在按钮上按?在细胞新闻? –
在单元格上按 –
请显示你调用的代码部分performSegueWithIdentifier –