UICollectionViewCell
のボタンからボタンのクリックイベントを得る方法はありますか?私はペンを使用してコレクションビューを作成しました。セルにはボタンがありますが、そのアクションは呼び出されません。問題は、代議員が呼び出されたことだと思います。これをどうすれば解決できますか?UICollectionViewでボタンをクリック
私が作成した方法:
- 追加空のペン先は、コレクションビューセル
- を追加しました.hと.Mファイルを作成し、
- が書いた 作成したクラスとして、細胞のペン先のファイルの所有者を作りましたクラス内のアクションアクション
にボタンを接続
- (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];
}
のですか?処置のリンクを削除して再接続してください。 –
質問を編集しました –
Close request?どうして? Oh ok編集済み –