में हैंडलिंग टैप जेस्चर है क्योंकि मैं एक फोटो एलबम बनाने के लिए किसी भी ढांचे का उपयोग नहीं कर सका, मैं संग्रह दृश्य का उपयोग करके अपना खुद का निर्माण करने की कोशिश कर रहा हूं, लेकिन मैं शुरुआत में ठीक हो गया।UICollectionView
मेरा लक्ष्य मेरी वेब सेवा से सभी छवियों को मेरे संग्रह दृश्य में प्रदर्शित करना है, क्योंकि सभी प्रदर्शित होते हैं, अगला चरण तब होता है जब कोई किसी भी सेल पर टैप करता है, मैं इसे एक नए दृश्य में खोल सकता हूं और सभी के बीच नेविगेट भी कर सकता हूं।
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[collectionController reloadData];
tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:nil action:@selector(touched)];
tapGesture.numberOfTapsRequired = 1;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 6;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"Cell";
CollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
[cell.imgCollection setImageWithURL:[NSURL URLWithString:@"http://sallescds.com.br/wp-content/uploads/2012/12/xepop-300x300.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
[cell.imgCollection addGestureRecognizer:tapGesture];
return cell;
}
-(void)touched:(UIGestureRecognizer *)tap{
NSLog(@"the touch happened");
}
धन्यवाद लोग:
यहाँ बुनियादी कोड है कि मैं बनाया है।
समझ लिया, मैं पहले से ही इन समस्याओं, तय मेरी गलती है जब मैं अंग्रेज़ी के लिए मेरे तरीकों के नाम का अनुवाद किया गया था। मदद के लिए धन्यवाद, अब मुझे इसे समझना है, UICollectionViewDelegate में ऐसा कैसे करें, क्योंकि मुझे कोई जानकारी नहीं है। क्या आप मुझे एक उदाहरण या ऐसा कुछ दे सकते हैं? –
ठीक है, इसलिए मुझे इस विधि को कॉल करना होगा - (BOOL) संग्रह दृश्य: (UICollectionView *) संग्रह दृश्य देखना चाहिए ItemAtIndexPath: (NSIndexPath *) indexPath; और इसके अंदर इशारा बनाओ? –
यह वास्तव में बहुत अधिक सरल है। यदि आप प्रतिनिधियों के तरीकों को लागू करते हैं, तो आपको इशारा पहचानकर्ताओं की आवश्यकता नहीं है। एक स्पर्श पता चला है जब प्रतिनिधि अपने तरीकों के कार्यान्वयन को बुलाएगा। ध्यान दें कि आपको स्पष्ट रूप से 'चाहिए चयन करें' या 'चयन किया गया' कॉल करने की आवश्यकता नहीं है, प्रतिनिधि यह आपके लिए करता है। –