【发布时间】:2015-10-09 12:39:51
【问题描述】:
我有一个带有页脚视图的 UICollectionView。页脚视图类是由我创建的。页脚视图是我想要执行操作的按钮。我尝试添加一项操作,但按下按钮时没有任何反应。请帮帮我。
我的代码:
FViewController.m
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *reusableview = nil;
if (kind == UICollectionElementKindSectionFooter) {
FooterCollectionReusableView *footerview = [[FooterCollectionReusableView alloc] init];
footerview = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView" forIndexPath:indexPath];
[footerview.todoButton addTarget:self action:@selector(todosPush:) forControlEvents:UIControlEventTouchUpInside];
reusableview = footerview;
}
return reusableview;
}
-(IBAction)todosPush:(id)sender{
NSLog(@"todosPush");
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
TipoEjercicioViewController *tipo = [storyBoard instantiateViewControllerWithIdentifier:@"TipoEjercicioView"];
tipo.ejercicio = 22;
[self.navigationController pushViewController:tipo animated:YES];
}
FooterCollectionReusableView.h
@interface FooterCollectionReusableView : UICollectionReusableView
@property (nonatomic, retain) IBOutlet UIButton * todoButton;
@end
【问题讨论】:
-
删除
UITapGestureRecognizer后试试 -
我试过了,但没有任何反应......
-
你用断点了吗?你的 todosPush 是否被调用了
-
试试这个
return (UICollectionReusableView *)footerview; -
您是否已将
todoButton与情节提要中的按钮连接
标签: ios objective-c uicollectionview action footer