Skip to content

v2panda/PDPullToRefresh

Repository files navigation

PDPullToRefresh

  • An easy way to use pull-to-refresh

Gif

Installation

From CocoaPods

Add pod 'PDPullToRefresh' to your Podfile or pod 'PDPullToRefresh', :head if you're feeling adventurous.

Manually

Important note if your project doesn't use ARC: you must add the -fobjc-arc compiler flag to UIScrollView+PDHeaderRefreshView.m and UIScrollView+PDFooterRefreshView.m in Target Settings > Build Phases > Compile Sources.

Drag the PDPullToRefresh/PDPullToRefresh folder into your project. Import PDPullToRefresh.h

Usage

(see sample Xcode project in /PDPullToRefresh)

Adding Pull to Refresh

[tableView pd_addHeaderRefreshWithNavigationBar:YES andActionHandler:^{
    // prepend data to dataSource, insert cells at top of table view
    // call [tableView.pdHeaderRefreshView stopRefreshing] when done
 }];

or if you want pull to refresh from the bottom

[tableView pd_addFooterRefreshWithNavigationBar:YES andActionHandler:^{
    // prepend data to dataSource, insert cells at top of table view
    // call [tableView.pdFooterRefreshView stopRefreshing] when done
 }];

If you’d like to programmatically trigger the refresh (for instance in viewDidAppear:), you can do so with:

[tableView.pdHeaderRefreshView startRefreshing];

Customization

The pull to refresh view can be customized using the following properties/methods:

@property (nonatomic, assign) CGFloat pdHeaderRefreshViewHeight;
@property (nonatomic, assign) CGFloat pdFooterRefreshViewHeight;

For instance, you would set the pdHeaderRefreshViewHeight property using:

// Default is 80
tableView.pdHeaderRefreshViewHeight = 100;

Special Thanks

PDPullToRefresh is Inspired by 半糖AppSVPullToRefresh

License

PDPullToRefresh is available under the MIT license. See the LICENSE file for more info.

About

An easy way to use pull-to-refresh

Resources

License

Stars

Watchers

Forks

Packages

No packages published