BOZPongRefreshControl

A pull-down-to-refresh control for iOS that plays pong, originally created for the MHacks III iOS app

  • 所有者: boztalay/BOZPongRefreshControl
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

BOZPongRefreshControl

A pull-down-to-refresh control for iOS that plays pong

Installation

It's on CocoaPods! Put pod 'BOZPongRefreshControl' in your Podfile.

Alternatively, just place BOZPongRefreshControl.h and BOZPongRefreshControl.m in your project anywhere you'd like.

Usage

Attach it to a UITableView or UIScrollView like so:

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    /* NOTE: Do NOT attach the refresh control in viewDidLoad!
     * If you do this here, it'll act very funny if you have
     * a navigation bar or other such similar thing that iOS
     * automatically offsets content for. You have to wait for
     * the subviews to get laid out first so the refresh
     * control knows how big that offset is!
     */
}

- (void)viewDidLayoutSubviews
{
    self.pongRefreshControl = [BOZPongRefreshControl attachToTableView:self.tableView
                                                     withRefreshTarget:self
                                                      andRefreshAction:@selector(refreshTriggered)];
}

Then, implement UIScrollViewDelegate in your UIViewController if you haven't already, and pass the calls through to the refresh control:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [self.pongRefreshControl scrollViewDidScroll];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    [self.pongRefreshControl scrollViewDidEndDragging];
}

Lastly, make sure you've implemented the refreshAction you passed it earlier to listen for refresh triggers:

- (void)refreshTriggered
{
    //Go and load some data

    //Finshed loading the data, reset the refresh control
    [self.pongRefreshControl finishedLoading];
}

For more details, check out the demo app's code. It has examples for using the refresh control on a UIScrollView and outside of a UITableViewController.

Configuration

  • Set the foreground color with the foregroundColor property
  • Set the background color with the backgroundColor property
  • Adjust how fast it plays by changing the totalHorizontalTravelTimeForBall property

Known Issues/To Do

  • It'll interfere with UIScrollView content that's above y = 0.0f
  • I haven't tested it, but I'd be willing to bet it looks a bit silly on iPads
  • Test it out on a physical iPhone 6+
  • The behavior of the paddles needs a little work
  • The the UIScrollView that it's attached to is scrolled automatically, the refresh control may be scrolled down into view under some circumstances (expanding/collapsing UITableViewCells, for example)
  • Tests!

主要指標

概覽
名稱與所有者boztalay/BOZPongRefreshControl
主編程語言Objective-C
編程語言Ruby (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2013-12-06 18:39:06
推送於2015-01-13 18:28:08
最后一次提交2015-01-13 13:28:08
發布數3
最新版本名稱1.0.1 (發布於 )
第一版名稱0.1.1 (發布於 )
用户参与
星數877
關注者數18
派生數64
提交數72
已啟用問題?
問題數10
打開的問題數4
拉請求數4
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?