1
我试图将信息发送到关于所选单元格的详细视图。现在,prepareForSegue在我使用的集合视图委托方法之前运行。这导致我发送前一个单元格选择的信息而不是当前单元格的信息。通过CollectionViewCell选择发送信息到详细视图
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
collectionView.deselectItemAtIndexPath(indexPath, animated: true)
nextScreenRow = indexPath.row
self.performSegueWithIdentifier("toDetails", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if segue.identifier == "toDetails" {
let vc = segue.destinationViewController as HistoryDetailsViewController
vc.postcard = postcards[nextScreenRow]
}
}
是否有可能,你必须从'collectionViewCell'到'HistoryDetailsViewController'一个SEGUE,并从当前视图控制器,它的另一个SEGUE也。 – gabbler 2014-12-13 02:50:46
“toDetails”是从collectionViewCell到HistoryDetailsViewController的继承。我在当前的视图控制器中也有一个展开顺序。 – Jerrod 2014-12-13 03:02:58
“toDetails”在故事板中定义,因此,您不必手动调用'performSegueWithIdentifier'来执行两次。 – gabbler 2014-12-13 03:11:19