vrw*_*wim 2 c# ios xamarin uicollectionview
我使用以下代码创建UIRefreshControl
:
_refreshControl = new UIRefreshControl();
_refreshControl.ValueChanged += RefreshTriggered;
_collectionView.InsertSubview(_refreshControl, 0);
Run Code Online (Sandbox Code Playgroud)
而且我不知道为什么UIRefreshControl
会被UICollectionViewCell
s 吸引.
以下是UICollectionView
我刚添加刷新控件时的子视图:
[0]: {<UIRefreshControl: 0x7c132fe0; frame = (0 0; 594 60); hidden = YES; autoresize = W; layer = <CALayer: 0x7c133250>>}
[1]: {<UIImageView: 0x79f8a5d0; frame = (3 588.5; 588 2.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x79f89a70>> - (null)}
[2]: {<UIImageView: 0x79fab7d0; frame = (588.5 584; 2.5 7); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x796171f0>> - (null)}
Run Code Online (Sandbox Code Playgroud)
以下是在UICollectionView中加载项目时的子视图:
[0]: {<MovieCollectionViewCell: 0x796e7350; baseClass = UICollectionViewCell; frame = (0 0; 183 278.16); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x7c244bc0>>}
[1]: {<MovieCollectionViewCell: 0x7c2b5850; baseClass = UICollectionViewCell; frame = (186 0; 183 278.16); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x7c2b5950>>}
[2]: {<MovieCollectionViewCell: 0x7c2ba7d0; baseClass = UICollectionViewCell; frame = (0 281; 183 278.16); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x7c2ba8d0>>}
[3]: {<MovieCollectionViewCell: 0x7c2bf440; baseClass = UICollectionViewCell; frame = (186 281; 183 278.16); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x7c2bf540>>}
[4]: {<MovieCollectionViewCell: 0x7c2c42d0; baseClass = UICollectionViewCell; frame = (0 562.5; 183 278.16); clipsToBounds = YES; hidden = YES; opaque = NO; layer = <CALayer: 0x7c2c43d0>>}
[5]: {<MovieCollectionViewCell: 0x7c2c9160; baseClass = UICollectionViewCell; frame = (186 562.5; 183 278.16); clipsToBounds = YES; hidden = YES; opaque = NO; layer = <CALayer: 0x7c2c9260>>}
[6]: {<UIRefreshControl: 0x7c132fe0; frame = (0 -69.5; 369 60); autoresize = W; layer = <CALayer: 0x7c133250>>}
[7]: {<UIImageView: 0x7c159e80; frame = (3 522; 363 2.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x7c159fb0>> - (null)}
[8]: {<UIImageView: 0x7c15a480; frame = (363.5 -66.5; 2.5 224); opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x7c15a5b0>> - (null)}
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?
尝试refreshControll
在布局过程后发送到后面,如下所示:
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self.collectionView sendSubviewToBack:self.refreshControl];
}
Run Code Online (Sandbox Code Playgroud)
由于UITableView
和UICollectionView
重用他们的细胞,他们奠定了其子视图(可能通过自定义实现的一个非常特殊的方式layoutSubviews
).因此,在布局过程之后,通常不会保留插入自定义子视图的位置.这就是为什么你必须覆盖viewDidLayoutSubviews
并将视图放回到你想要的位置.
UIRefreshControll
被自动检测UITableView
并放回到其他子视图后面,但情况并非如此UICollectionView
,您必须手动执行.而对于任何其他自定义子视图,你必须做两个UITableView
和UICollectionView
.
归档时间: |
|
查看次数: |
311 次 |
最近记录: |