そのため、UICollectionView の補足ビューにジェスチャ認識機能を追加するためにインターフェイス ビルダーを使用 できないようです。
これは、.xib が読み込まれると、UICollectionView がスーパービューに 1 つのものとして表示される必要があるためだと思います。また、その UICollectionView にジェスチャ レコグナイザーを追加すると、スーパービュー レベルで 2 つのものになり、どちらもUICollectionView.
ただし、UICollectionViewReusableView プロトコル内の補足ビューの定義を使用して、プログラムでジェスチャ レコグナイザーを実装できます。(if は、コードの後半でヘッダー補足ビューとフッター補足ビューを区別するために使用されています)
if (kind == UICollectionElementKindSectionHeader) {
MyHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MY_HEADER" forIndexPath:indexPath];
// call headerView methods (to put things into the header's UI objects for example)
[headerView ...];
[headerView ...];
[headerView ...];
// add gesture recognition for tapping on a UIlabel within the header (UICollectionView supplementary view)
UITapGestureRecognizer *bioTap = [[UITapGestureRecognizer alloc] initWithTarget:headerView action:@selector(handleUILabelTap:)];
// make your gesture recognizer priority
bioTap.delaysTouchesBegan = YES;
bioTap.numberOfTapsRequired = 1;
[headerView.UILabelName addGestureRecognizer:UILabelTap];
reusableview = headerView;
}