Nic*_*247 3 objective-c ios uicollectionview uirefreshcontrol
我在集合视图中添加了一个刷新控件。一切正常,但是当我设置 collectionView.contentInset = UIEdgeInsetsMake(0, 20, 20, 20) 时,刷新控件的宽度保持不变但移动了 20px,因此不在视图中居中。控件应该减少 40px 才能正确。
self.collectionView = [[UICollectionView alloc] initWithFrame:rect collectionViewLayout:flowLayout];
self.collectionView.contentInset = UIEdgeInsetsMake(0, 20, 20, 20)
UIRefreshControl* pullDownRefresh = [[UIRefreshControl alloc] init];
[pullDownRefresh addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:pullDownRefresh];
Run Code Online (Sandbox Code Playgroud)
我尝试在添加视图(也在 viewWillLayoutSubviews 中)后手动设置宽度,并尝试使用 autoresizingMask 无济于事。
有任何想法吗?我想我需要将它放在容器视图中......但不需要!
Nic*_*247 12
好的,通过不设置 collectionView.contentInset 解决了问题。相反,我在 flowLayout 上设置
IE
flowLayout.sectionInset = UIEdgeInsetsMake(0, 20, 20, 20);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
874 次 |
| 最近记录: |