1
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(identifier, forIndexPath: indexPath) as! ComposeCell
cell.deletePictureSignal.subscribeNext { (response) -> Void in
print("delete picture")
let deleteIndex = (self.pictureView.indexPathForCell(cell)?.item)!
self.pictures.removeAtIndex(deleteIndex)
// self.pictureView.reloadData()
}
cell.addPictureSignal.subscribeNext { (response) -> Void in
print("add picture")
self.selectedIndex = (self.pictureView.indexPathForCell(cell)?.item)!
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion: nil)
}
return cell
}
當我reloadData,這樣將再次實施,信號將被訂閱很多時候,我怎麼能解決這個問題,並確保訂閱只有一次?ReactiveCocoa - 如何避免多認購信號的CollectionView的細胞