All Projects → pronebird → Uiscrollview Infinitescroll

pronebird / Uiscrollview Infinitescroll

Licence: mit
UIScrollView ∞ scroll category

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Uiscrollview Infinitescroll

InfiniteScrollRecyclerView
Enables the RecyclerView to Auto scroll for indefinite time.
Stars: ✭ 49 (-94.88%)
Mutual labels:  infinite-scroll, scrollview
Pull To Refresh
ESPullToRefresh is developed and maintained by Vincent Li. If you have any questions or issues in using ESPullToRefresh, welcome to issue. If you want to contribute to ESPullToRefresh, Please submit Pull Request, I will deal with it as soon as possible.
Stars: ✭ 1,591 (+66.25%)
Mutual labels:  infinite-scroll, scrollview
Fancyscrollview
[Unity] A scrollview component that can implement highly flexible animations.
Stars: ✭ 1,216 (+27.06%)
Mutual labels:  infinite-scroll, scrollview
Rsdayflow
iOS 7+ Calendar (Date Picker) with Infinite Scrolling.
Stars: ✭ 843 (-11.91%)
Mutual labels:  infinite-scroll, scrollview
Txscrolllabelview
🌭TXScrollLabelView, the best way to show & display information such as adverts / boardcast / onsale e.g. with a customView.
Stars: ✭ 714 (-25.39%)
Mutual labels:  scrollview
Yjbannerview
【抱歉,暂时不提供开源】A very popular and highly customized banner view, 无限循环滚动轮播图BannerView、焦点图, 支持Cocoapods 及 Carthage. 支持完全自定义
Stars: ✭ 506 (-47.13%)
Mutual labels:  scrollview
Jt3dscrollview
ScrollView with custom effects during the scroll for iOS
Stars: ✭ 494 (-48.38%)
Mutual labels:  scrollview
Immersivedetailsample
A sample application show how to realize immersive parallax effect header like Google Play Store
Stars: ✭ 457 (-52.25%)
Mutual labels:  scrollview
Smkcyclescrollview
SMKCycleScrollView - An awesome advertisement cycleScrollView
Stars: ✭ 11 (-98.85%)
Mutual labels:  scrollview
Ltscrollview
ScrollView嵌套ScrolloView(UITableView 、UICollectionView)解决方案, 支持OC / Swift(持续更新中...)实现原理:http://blog.csdn.net/glt_code/article/details/78576628
Stars: ✭ 897 (-6.27%)
Mutual labels:  scrollview
Vue Pull To
⚡️ A pull-down refresh and pull-up load more and infinite scroll component for Vue.js --Vue下拉刷新组件
Stars: ✭ 708 (-26.02%)
Mutual labels:  infinite-scroll
Vue Mugen Scroll
Infinite scroll component for Vue.js 2
Stars: ✭ 532 (-44.41%)
Mutual labels:  infinite-scroll
Infinite Ajax Scroll
Turn your existing pagination into infinite scrolling pages with ease
Stars: ✭ 804 (-15.99%)
Mutual labels:  infinite-scroll
React Native Ultimate Listview
A high performance FlatList providing customised pull-to-refresh | auto-pagination & infinite-scrolling | gridview layout | swipeable-row.
Stars: ✭ 497 (-48.07%)
Mutual labels:  infinite-scroll
Django Photoblog
Photographer portfolio website powered by Django Framework. Features photo gallery with infinite scrolling, tagging, thumbnail generation and CMS for creating pages. Configured for Heroku and S3.
Stars: ✭ 19 (-98.01%)
Mutual labels:  infinite-scroll
Vegile
This tool will setting up your backdoor/rootkits when backdoor already setup it will be hidden your spesisifc process,unlimited your session in metasploit and transparent. Even when it killed, it will re-run again. There always be a procces which while run another process,So we can assume that this procces is unstopable like a Ghost in The Shell
Stars: ✭ 478 (-50.05%)
Mutual labels:  infinite-scroll
React Native Sortable List
React Native Sortable List component
Stars: ✭ 678 (-29.15%)
Mutual labels:  scrollview
Swipemenu
[DEPRECATED] A swipe menu for horizontal/vertical, support left/right and top/bottom directions
Stars: ✭ 817 (-14.63%)
Mutual labels:  scrollview
Infinitecycleviewpager
Infinite cycle ViewPager with two-way orientation and interactive effect.
Stars: ✭ 5,720 (+497.7%)
Mutual labels:  infinite-scroll
Tysnapshotscroll
一句代码保存截图,将 UIScrollView UITableView UICollectionView UIWebView WKWebView 网页 保存 为 长图 查看。Save the scroll view page as an image,support UIScrollView,UITableView,UICollectionView,UIWebView,WKWebView.(Support iOS13)
Stars: ✭ 709 (-25.91%)
Mutual labels:  scrollview

UIScrollView+InfiniteScroll

Infinite scroll implementation as a category for UIScrollView.

* The content used in demo app is publicly available and provided by hn.algolia.com and Flickr. Both can be inappropriate.

Swizzling

Be aware that this category swizzles setContentOffset and setContentSize on UIScrollView.

CocoaPods

Just add the following line in your Podfile:

pod 'UIScrollView-InfiniteScroll', '~> 1.2.0'

Carthage

Just add the following line in your Cartfile:

github "pronebird/UIScrollView-InfiniteScroll" ~> 1.2.0

Examples

This component comes with example app written in Swift and Objective-C.

If you use CocoaPods you can try it by running:

pod try UIScrollView-InfiniteScroll

Documentation

http://pronebird.github.io/UIScrollView-InfiniteScroll/

Before using module

Objective-C

Import header file in Objective-C:

#import <UIScrollView_InfiniteScroll/UIScrollView+InfiniteScroll.h>

Swift

Add the following line in your bridging header file:

#import <UIScrollView_InfiniteScroll/UIScrollView+InfiniteScroll.h>

Basics

In order to enable infinite scroll you have to provide a handler block using addInfiniteScrollWithHandler. The block you provide is executed each time infinite scroll component detects that more data needs to be provided.

The purpose of the handler block is to perform asynchronous task, typically networking or database fetch, and update your scroll view or scroll view subclass.

The block itself is called on main queue, therefore make sure you move any long-running tasks to background queue. Once you receive new data, update table view by adding new rows and sections, then call finishInfiniteScroll to complete infinite scroll animations and reset the state of infinite scroll components.

viewDidLoad is a good place to install handler block.

Make sure that any interactions with UIKit or methods provided by Infinite Scroll happen on main queue. Use dispatch_async(dispatch_get_main_queue, { ... }) in Objective-C or DispatchQueue.main.async { ... } in Swift to run UI related calls on main queue.

Many people make mistake by using external reference to table view or collection view within the handler block. Don't do this. This creates a circular retention. Instead use the instance of scroll view or scroll view subclass passed as first argument to handler block.

Objective-C

// setup infinite scroll
[tableView addInfiniteScrollWithHandler:^(UITableView* tableView) {
    // update table view
    
    // finish infinite scroll animation
    [tableView finishInfiniteScroll];
}];

Swift

tableView.addInfiniteScroll { (tableView) -> Void in
    // update table view
            
    // finish infinite scroll animation
    tableView.finishInfiniteScroll()
}

Collection view quirks

UICollectionView.reloadData causes contentOffset to reset. Instead use UICollectionView.performBatchUpdates when possible.

Objective-C

[self.collectionView addInfiniteScrollWithHandler:^(UICollectionView* collectionView) {    
    [collectionView performBatchUpdates:^{
        // update collection view
    } completion:^(BOOL finished) {
        // finish infinite scroll animations
        [collectionView finishInfiniteScroll];
    }];
}];

Swift

collectionView.addInfiniteScroll { (collectionView) -> Void in
    collectionView.performBatchUpdates({ () -> Void in
        // update collection view
    }, completion: { (finished) -> Void in
        // finish infinite scroll animations
        collectionView.finishInfiniteScroll()
    });
}

Start infinite scroll programmatically

You can reuse infinite scroll flow to load initial data or fetch more using beginInfiniteScroll(forceScroll). viewDidLoad is a good place for loading initial data, however absolutely up to you to decide.

When forceScroll parameter is positive, Infinite Scroll component will attempt to scroll down to reveal indicator view. Keep in mind that scrolling will not happen if user is interacting with scroll view.

Objective-C

[self.tableView beginInfiniteScroll:YES];

Swift

tableView.beginInfiniteScroll(true)

Prevent infinite scroll

Sometimes you need to prevent the infinite scroll from continuing. For example, if your search API has no more results, it does not make sense to keep making the requests or to show the spinner.

Objective-C

[tableView setShouldShowInfiniteScrollHandler:^BOOL (UITableView *tableView) {
    // Only show up to 5 pages then prevent the infinite scroll
    return (weakSelf.currentPage < 5);
}];

Swift

// Provide a block to be called right before a infinite scroll event is triggered.  Return YES to allow or NO to prevent it from triggering.
tableView.setShouldShowInfiniteScrollHandler { _ -> Bool in
    // Only show up to 5 pages then prevent the infinite scroll
    return currentPage < 5 
}

Seamlessly preload content

Ideally you want your content to flow seamlessly without ever showing a spinner. Infinite scroll offers an option to specify offset in points that will be used to start preloader before user reaches the bottom of scroll view.

The proper balance between the number of results you load each time and large enough offset should give your users a decent experience. Most likely you will have to come up with your own formula for the combination of those based on kind of content and device dimensions.

// Preload more data 500pt before reaching the bottom of scroll view.
tableView.infiniteScrollTriggerOffset = 500;

Custom indicator

You can use custom indicator instead of default UIActivityIndicatorView.

Custom indicator must be a subclass of UIView and implement the following methods:

- (void)startAnimating;
- (void)stopAnimating;

Objective-C

CustomInfiniteIndicator *infiniteIndicator = [[CustomInfiniteIndicator alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
self.tableView.infiniteScrollIndicatorView = indicator;

Swift

let frame = CGRect(x: 0, y: 0, width: 24, height: 24)
tableView.infiniteScrollIndicatorView = CustomInfiniteIndicator(frame: frame)

Please see example implementation of custom indicator view:

At the moment InfiniteScroll uses indicator's frame directly so make sure you size custom indicator view beforehand. Such views as UIImageView or UIActivityIndicatorView will automatically resize themselves so no need to setup frame for them.

Contributors

Please see CHANGES

Attributions

Demo app icon by PixelResort.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].