Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在状态变化时,我不太明白当初为什么单独在UI切换至MJRefreshStateRefreshing状态时使用DispatchAsync,而在切换至MJRefreshStateIdle状态时不使用DispatchAsync。
我认为setState的调用者应该确保在主线程调用的,而不是在set方法内再用异步分发到主线程。
这里做DispatchAsync只会造成一个严重点问题:
如果beginRefreshing和endRefreshing在很近的时间段调用(这很常见,比如网络请求完成调用endRefreshing后,刚好用户又点击了TabBar按钮触发beginRefreshing),由于异步分发,可能会先执行恢复滚动区域再执行增加滚动区域, 造成头部累积增加contentInset.top,体验相当糟糕。
所以我去掉了MJRefreshDispatchAsyncOnMainQueue()部分,经过有限的测试没有发现其他问题。