Ale*_*son 3 ios uicollectionview
我正在使用一个水平选择器UICollectionView.它很简单:A UIView以UICollectionView编程方式创建,使用UICollectionViewFlowLayout一个部分,滚动设置为水平.它出现在屏幕上,在正确的单元格中显示正确的数据.但它不会滚动 - 实际上它根本不响应用户交互.
这是视图的初始化程序:
- (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;
}
Run Code Online (Sandbox Code Playgroud)
我尝试以编程方式设置UserInteractionEnabled为YES,但这没有任何区别(也不应该有,因为默认UserInteractionEnabled设置为YES).FWIW,集合视图使用标准UICollectionViewCells,s作为子视图UILabel添加到contentViews中.
有没有想过为什么这不滚动?任何和所有帮助非常感谢.
| 归档时间: |
|
| 查看次数: |
12424 次 |
| 最近记录: |