問題是這樣的線回零: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 –