Lit*_*T.V 5 delegates ipad ios uicollectionview uicollectionviewcell
有没有办法从一个按钮内部获取按钮点击事件UICollectionViewCell?我用一个笔尖来填充集合视图,单元格有按钮但是它的动作没有被调用.我认为问题在于调用委托.我怎样才能解决这个问题?
我是如何创造的:
有没有办法让我采取行动?我究竟做错了什么?
小智 10
像这样添加按钮动作:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CellId" forIndexPath:[indexPath row]];
[[cell myButton] addTarget:self action:@selector(myClickEvent:event:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (IBAction)myClickEvent:(id)sender event:(id)event {
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:_myCollectionArray];
NSIndexPath *indexPath = [_myCollectionArray indexPathForItemAtPoint: currentTouchPosition];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18923 次 |
| 最近记录: |