pronebird / UIScrollView-InfiniteScroll

UIScrollView ∞ scroll category
MIT License
1.06k stars 148 forks source link

Activity Indicator hides a little late #17

Closed vinod93 closed 6 years ago

vinod93 commented 9 years ago

After fetching the data from server, when the new collection view items are inserted then the activity indicator hides late for 1 sec. What i want to do is to hide the activity indicator before the items are inserted, so inorder to resolve this what has to be done.

Thank you.

pronebird commented 9 years ago

Hello! That does not sound right. Do you call finishInfiniteScroll from the main thread? Also I suggest you take a look at demo app which uses collection view and everything seems to work fine.

vinod93 commented 9 years ago

Yes I did called it on main thread just like in the demo. The problem that I'm having is the activity indicator stops animating almost 1sec later i.e., after the new items are inserted and on the call of the finish() block the finishInfiniteScroll method gets called & it take a delay.

...
[self.collectionView insertItemsAtIndexPaths:arrayWithIndexPath];
}
 completion:^(BOOL finished) {
                        finish();
                    }]; 

So my concern here is how to solve this delaying issue.

pronebird commented 9 years ago

Could you please prepare a sample project reproducing this issue? I looked at the demo today and I didn't notice any delay.

pronebird commented 9 years ago

Oh yeah, I think I see what you mean. It's in fact disappears with a short delay.

vinod93 commented 9 years ago

https://drive.google.com/file/d/0B3Q2nuVLZgySY3lOZlp0bDZMN0U/view?usp=sharing

You can have a look at the video demo. Also i'll tell you what I have changed from the demo code.

instead of

    // Create custom indicator
CustomInfiniteIndicator *indicator = [[CustomInfiniteIndicator alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]; 

I have created the default indicator

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

and finally assigned it to this

// Set custom indicator
    self.collectionView.infiniteScrollIndicatorView = indicator;
vinod93 commented 9 years ago

Yes so what can be done to correct that. Please.

pronebird commented 9 years ago

Thanks for all your suggestions and video that you recorded and sorry for a late reply.

I know it does not look as good as it could be but I think there is not much to be done here. Apparently collection view delays the completion handler I assume to finish pending animations, that's why finishInfiniteScroll kicks in too late. I don't see how this issue can be solved with the public APIs that Apple provides us.

doseAt commented 7 years ago

Hello pronebird. In the example project the animation of loading last about 5-6 seconds. The content in example project is very light, it should be pulled from server for max second or two, why it last so long?

pronebird commented 7 years ago

@doseAt I don't think this issue is about that. In example project artificial delay introduced for demo purposes, exactly because the content is very light and loads very fast.

doseAt commented 7 years ago

@pronebird well i have a problem like that in my own project, loading bar keeps loading even after the pull from server is done and tableView.finishInfiniteScroll() is called. What can i try, and where can i find more docs about plugin?

pronebird commented 7 years ago

@doseAt would you mind creating a separate issue and trying to create a minimal project to reproduce your issue? Most of the time problems like that arise because finishInfiniteScroll() is called on background thread.

pronebird commented 7 years ago

@doseAt documentation is generated from source code and available at http://cocoadocs.org/docsets/UIScrollView-InfiniteScroll/0.9.1/

pronebird commented 6 years ago

Closing because there is not much can be done, UICollectionView calls completionHandler a little late. You may want to file a radar with Apple.