आपके पास प्रतिनिधि में collectionView:didSelectItemAtIndexPath:
विधि है। जब आप सेल एकत्र करते हैं और उस विशेष सेल के लिए आपको सही इंडेक्सपैथ देते हैं तो यह आग लगनी चाहिए।
किसी विशेष सेल तक पहुंचने के लिए संग्रहView के cellForItemAtIndexPath:
के साथ संयोजन में इस अनुक्रमणिका का उपयोग करें।
उदाहरण:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[self manipulateCellAtIndexPath:indexPath];
}
-(void) manipulateCellAtIndexPath:(NSIndexPath*)indexPath {
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];
// Now do what you want...
}
और, जब तक मैं यहाँ हूँ के रूप में। स्विफ्ट संस्करण:
override func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath) {
manipulateCellAtIndexPath(indexPath)
}
func manipulateCellAtIndexPath(indexPath: NSIndexPath) {
if let cell = collectionView?.cellForItemAtIndexPath(indexPath) {
// manipulate cell
}
}
स्रोत
2013-02-02 09:45:45