を使用して水平ピッカーを作成していUICollectionView
ます。UIView
それは非常に簡単です:UICollectionView
プログラムで作成された A を使用UICollectionViewFlowLayout
し、1 つのセクションを使用して、スクロールを水平に設定します。画面に表示され、正しいセルに正しいデータが表示されます。しかし、スクロールはしません。実際、ユーザーの操作にはまったく反応しません。
ビューの初期化子は次のとおりです。
- (id)initWithFrame:(CGRect)frame andItemData:(NSArray *)itemData
{
self = [super initWithFrame:frame];
if (self) {
_itemData = itemData;
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
[flowLayout setItemSize:CGSizeMake(kCellWidth, kCellHeight)];
[flowLayout setMinimumInteritemSpacing:0.f];
[flowLayout setMinimumLineSpacing:0.f];
_collectionView = [[UICollectionView alloc] initWithFrame:[self frame] collectionViewLayout:flowLayout];
[_collectionView setDataSource:self];
[_collectionView setDelegate:self];
[_collectionView setBounces:NO];
[_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"HorizontalPickerCell"];
[self addSubview:_collectionView];
}
return self;
}
プログラムで に設定しようとしUserInteractionEnabled
ましYES
たが、違いはありませんでした (デフォルトUserInteractionEnabled
で に設定されているため、違いはありませんYES
)。FWIW、コレクション ビューは標準UICollectionViewCell
の を使用し、がサブビューとしてUILabel
に追加されます。contentView
これがスクロールしない理由について何か考えはありますか? ありとあらゆる助けが大歓迎です。