• Stars
    star
    882
  • Rank 51,756 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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!

More Repositories

1

Erudite

MHacks V hack, a Google Glass app that listens to your conversation and lets you pull the Wikipedia page for certain words, so you can sound smarter
Java
7
star
2

BezierRenderer

A simple bezier curve renderer in Python that can draw curves of arbitrary order
Python
6
star
3

AndroidPullToPong

Pull-to-refresh for Android that plays pong
Java
5
star
4

RootbeerOfLife

An implementation of Conway's Game of Life using Rootbeer to run it on the GPU
Java
3
star
5

PuppyFrame

An Android widget that displays selected pictures on your home screen
Java
3
star
6

UmichClassChecker

A Google App Engine web app in Go to periodically check the availability of classes at the University of Michigan and notify users of changes in availability
Go
3
star
7

TaskScheduler

A simple iOS app that automatically schedules tasks into daily lists for you
Swift
2
star
8

LappyLogger

A tool to log various statistics about the usage of my laptop, like battery level
Objective-C
2
star
9

IceTubeClock

A clock with ice tubes for its display
Prolog
1
star
10

HandAndFoot

An iOS app and Flask backend to remotely play the card game Hand and Foot
Swift
1
star
11

EagleLibrary

My personal parts library for EAGLE
1
star
12

HabitTracker

A simple iOS app to track how often you give into a bad habit, made mainly to mess around with Today extensions
Swift
1
star
13

OZ-3

A small RISC processor, designed in Logisim and implemented on a Xilinx FPGA using VHDL
VHDL
1
star
14

ArduinoGameOfLife

Game of life on an Arduino using a Michigan Hackers LED shield
Arduino
1
star
15

MyoLIFXControl

An iOS app that lets you control LIFX bulbs with a Myo band
Objective-C
1
star
16

GameOfLifeScreenSaver

A macOS screen saver running Conway's Game of Life
Swift
1
star