【发布时间】:2018-06-20 15:54:18
【问题描述】:
我在集合视图中添加了一个刷新控件。一切正常,但是当我设置 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];
我尝试在添加视图后手动设置宽度(也在 viewWillLayoutSubviews 中),但使用 autoresizingMask 无济于事。
有什么想法吗?我想我需要将它放在容器视图中......但不需要!
【问题讨论】:
-
容器视图不起作用,因为 UIRefreshControl 断言如果未添加到滚动视图!
标签: ios objective-c uicollectionview uirefreshcontrol