Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

悬浮头部布局错乱问题 #16

Closed
AlmostSir777 opened this issue May 10, 2019 · 11 comments
Closed

悬浮头部布局错乱问题 #16

AlmostSir777 opened this issue May 10, 2019 · 11 comments

Comments

@AlmostSir777
Copy link

就是我有个页面是问卷考察的页面,是纵向布局的,两列的,设置了ClosedLayout类型,选项可以展开和收起,我头部设置了悬浮。滚动一定位置后,点击头部的收起,然后头部布局会错乱,item都是好的,头部会显示在最底部,滚动又变好了,现在为了实现需求头部设置了固定。

@czl0325
Copy link
Owner

czl0325 commented May 10, 2019

展开和收起的时候需要reloaddata一下,有时候reloaddata还不能马上执行,设置延时0.01秒执行

@AlmostSir777
Copy link
Author

最后这样处理的,感觉有点low,
[self.collectionView reloadData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,(int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self scrollViewDidScroll:self.collectionView];
});

@czl0325
Copy link
Owner

czl0325 commented May 10, 2019

dispatch_after(dispatch_time(DISPATCH_TIME_NOW,(int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.collectionView reloadData];
});

直接这样既可!

@AlmostSir777
Copy link
Author

还是会偶发错乱问题,都试过了,代理也就那几个代理,也没写错啊,有点懵

@czl0325
Copy link
Owner

czl0325 commented May 10, 2019

照理说只要延迟执行一下reloadData就可以了,我以前也是这么做的

@czl0325
Copy link
Owner

czl0325 commented May 10, 2019

[self.collectionViewLabel performSelector:@selector(reloadData) withObject:nil afterDelay:0.01];

这样试看看

@AlmostSir777
Copy link
Author

好的,谢谢了

@czl0325
Copy link
Owner

czl0325 commented May 10, 2019

如果不行把延迟时间加长,0.1秒

@AlmostSir777
Copy link
Author

先reloadData一次,然后延时再reloadData一次,就没出问题了,哈哈

@czl0325
Copy link
Owner

czl0325 commented May 10, 2019

直接延时reloadData吧,第一次reloadData应该是没用的,我之前试过

@AlmostSir777
Copy link
Author

嗯嗯,谢了,博主

@czl0325 czl0325 closed this as completed May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants