У меня есть коллекция [не customviewview], и я хотел бы показать предупреждение, нажав кнопку. Но действие кнопки не определяет действие, которое является моим кодом:Cant detect button action collectionview
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [ self.collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
NSArray *sectionArr=[self.ClassesArr objectAtIndex:indexPath.section];
NSDictionary *data = [sectionArr objectAtIndex:indexPath.row];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(54, 25, 15, 15);
[btn addTarget:self action:@selector(subCateBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:btn];
}
// the button action
-(IBAction)subCateBtnAction:(UIButton *)btn
{
NSArray *sectionArr=[self.ClassesArr objectAtIndex:sectionindex];
NSDictionary *data = [sectionArr objectAtIndex:btn.tag];
NSString *name = [data objectForKey:@"nombreTarifa"];
UIAlertView *Notpermitted=[[UIAlertView alloc] initWithTitle:@""
message:name
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[Notpermitted show];
}
В чем проблема?
http://stackoverflow.com/questions/13757762/getting-button-action-uicollectionview -cell Возможно, это поможет вам – NeoJiang