pronebird / UIScrollView-InfiniteScroll

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

How to change position of loading indicator? #53

Closed mengheangrat closed 7 years ago

mengheangrat commented 7 years ago

simulator screen shot dec 29 2016 10 48 41 am copy

pronebird commented 7 years ago

You can control vertical margin via infiniteScrollIndicatorMargin. Default margin is set at 11pt, along with 22pt default activity indicator this gives us around 44pt indicator row which is the same as default cell size, with custom size indicator this does not hold true anymore so you have to adjust the number for your needs.

Documentation is available at:

http://pronebird.github.io/UIScrollView-InfiniteScroll/Categories/UIScrollView(InfiniteScroll).html#/c:objc(cs)UIScrollView(py)infiniteScrollIndicatorMargin

mengheangrat commented 7 years ago

collectionView?.infiniteScrollIndicatorView = CustomInfiniteIndicator(frame: CGRect(x: 0, y: -70, width: 35, height: 35)) // Set custom indicator margin collectionView!.infiniteScrollIndicatorMargin = 70 // Add infinite scroll handler collectionView!.addInfiniteScroll { [weak self] (scrollView) -> Void in self?.fetchDataFresh(){ scrollView.finishInfiniteScroll() } } collectionView!.infiniteScrollTriggerOffset = 100 refreshControl.addTarget(self, action: #selector(self.refreshData), for: UIControlEvents.valueChanged) self.collectionView!.addSubview(refreshControl) Still not working

pronebird commented 7 years ago

So roughly that's how it should be:

infinitescrollindicatormargin

Even with refresh control in everything works as expected here testing with iOS 10.2 simulator. Please refer to demo app coming with the library. Maybe it will help you to spot the problem.

If you use custom flow layout, make sure that your layout produces the correct content size. InfiniteScroll works with contentInset only to add extra spacing to accommodate indicator view.

Also, it would be easier to understand what is going on if you provided entire screenshot. Indicator always appears below tabbar or screen boundaries. If you don't have enough content it will bump content inset to cover that to ensure that it does not appear out of nowhere. (case when content size is smaller than view bounds)

mengheangrat commented 7 years ago

@pronebird Now It's worked. It's error because of add infiniteScrollTriggerOffset after addInfiniteScroll

Thank you so much.