【发布时间】:2016-07-08 01:08:37
【问题描述】:
问题是这一行返回 nil:
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 的代码部分
-
把你调用 performSegueWithIdentifier 的那部分代码放在哪里
标签: ios objective-c swift swift2