Skip to content

Latest commit

 

History

History
54 lines (48 loc) · 1.29 KB

README.md

File metadata and controls

54 lines (48 loc) · 1.29 KB

RefreshableTableViewController

EGOTableViewPullRefresh with infinite-scrolling superpowers for RubyMotion.

endorse

NOTE: The example app is based on the demo app "Tweets" from the HipByte's RubyMotionSamples.

Usage

Controller setup

# Inherit all the magic
class TweetsController < RefreshableTableViewController
  # ...
  def viewDidLoad
    # Must call super to allow Refreshable load its initial setup
    super
    # ...
  end
end

Infinite scrolling

def viewDidLoad
  # ...
  # Get older tweets when scrolling reaches bottom of table view
  @callbacks[:infinite_scroll] = lambda {
    get_tweets(max_id: @tweets.lastObject.id) if @tweets.lastObject
  }
end

Pull to refresh

# Override pull to refresh handler to download new tweets
def refreshTableHeaderDidTriggerRefresh(view)
  get_tweets(since_id: @tweets.first.id) if @tweets.first
end

def your_downloader_callback
  # ...
  # Stop pull-to-refresh loading animation
  doneReloadingTableViewData
end

References and attributions: