• Stars
    star
    2,828
  • Rank 15,994 (Top 0.4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 8 years ago

Reviews

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

Repository Details

A simple view for building card like interface inspired by Tinder and Potluck.

ZLSwipeableView

Build Status Gitter

A simple view for building card like interface like Tinder and Potluck. ZLSwipeableView was originally developed for Murmur.

Notice: The Objective-C version of ZLSwipeableView is no longer actively maintained.

Please checkout the swift version: https://github.com/zhxnlai/ZLSwipeableViewSwift

Preview

###Swipe swipe ###Swipe Cancel cancel ###Swipe Programmatically swipeLeft ###Swipe Programmatically II swipeLeftRight

CocoaPods

You can install ZLSwipeableView through CocoaPods adding the following to your Podfile:

pod 'ZLSwipeableView'

Usage

Check out the demo app for an example.

ZLSwipeableView can be added to storyboard or instantiated programmatically:

ZLSwipeableView *swipeableView = [[ZLSwipeableView alloc] initWithFrame:self.view.frame];
[self.view addSubview:swipeableView];

A ZLSwipeableView must have an object that implements ZLSwipeableViewDataSource to act as a data source. ZLSwipeableView will prefetch three views in advance to animate them.

// required data source
self.swipeableView.dataSource = self;

#pragma mark - ZLSwipeableViewDataSource
- (UIView *)nextViewForSwipeableView:(ZLSwipeableView *)swipeableView {
  return [[UIView alloc] init];
}

The demo app includes examples of both creating views programmatically and loading views from Xib files that use Auto Layout.

A ZLSwipeableView can have an optional delegate to receive callback.

// optional delegate
self.swipeableView.delegate = self;

#pragma mark - ZLSwipeableViewDelegate
- (void)swipeableView:(ZLSwipeableView *)swipeableView
         didSwipeView:(UIView *)view
          inDirection:(ZLSwipeableViewDirection)direction {
    NSLog(@"did swipe in direction: %zd", direction);
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView didCancelSwipe:(UIView *)view {
  NSLog(@"did cancel swipe");
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView didStartSwipingView:(UIView *)view atLocation:(CGPoint)location {
    NSLog(@"did start swiping at location: x %f, y%f", location.x, location.y);
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView swipingView:(UIView *)view atLocation:(CGPoint)location  translation:(CGPoint)translation {
	NSLog(@"swiping at location: x %f, y %f, translation: x %f, y %f", location.x, location.y, translation.x, translation.y);
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView didEndSwipingView:(UIView *)view atLocation:(CGPoint)location {
    NSLog(@"did start swiping at location: x %f, y%f", location.x, location.y);
}

To swipe the top view programmatically:

[self.swipeableView swipeTopViewToLeft];
[self.swipeableView swipeTopViewToRight];
...

To discard all views and reload programmatically:

[self.swipeableView discardAllViews];
[self.swipeableView loadViewsIfNeeded];

Requirements

  • iOS 7 or higher.
  • Automatic Reference Counting (ARC).

Credits

  • Thanks iamphill for adding new delegates.
  • Thanks mdznr for making the code style consistent.
  • Thanks coryalder for making dataSource and delegate IBOutlets.

License

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

More Repositories

1

ZLSwipeableViewSwift

A simple view for building card like interface inspired by Tinder and Potluck.
Swift
2,235
star
2

ZLBalancedFlowLayout

A UICollectionViewFlowLayout subclass that scales items to take up space, optimized for large item set, inspired by NHBalancedFlowLayout.
Swift
309
star
3

ZLSinusWaveView

A Siri like voice visualization view using EZAudio. Modified from SISinusWaveView for iOS.
Objective-C
283
star
4

ZLMusicFlowWaveView

A ZLSinusWaveView subclass inspired by 乐流/MusicFlow
Objective-C
202
star
5

ZLPeoplePickerViewController

A multilingual replacement for ABPeoplePickerNavigationController (address book picker) that supports UILocalized​Indexed​Collation
Objective-C
189
star
6

ZLHistogramAudioPlot

A hardware-accelerated audio visualization view using EZAudio, inspired by AudioCopy.
Objective-C
185
star
7

UIColor-ChineseTraditionalColors

A swift extension that extends UIColor with a list of Chinese traditional colors
Swift
132
star
8

AsyncTask

An asynchronous programming library for Swift
Swift
130
star
9

react-webgl-globe-basic-example

WebGL Globe basic example in react
JavaScript
70
star
10

Async

Async, await control flow for Swift.
Swift
69
star
11

Algorithms

Answers to LeetCode questions in Swift and JavaScript
Swift
52
star
12

ReactiveUI

A lightweight replacement for target action with closures, modified from Scream.swift.
Swift
51
star
13

Emoticon

An Emoticon Keyboard
Swift
22
star
14

wwdc

WWDC 2015 Student Scholarship App
Swift
6
star
15

printf

A web based visualizer for printf format string
JavaScript
6
star
16

YelpAPI

Yelp API in Swift
Swift
5
star
17

TicketsTonight

UCLA CS130 Fall 2014 Class Project
Objective-C
4
star
18

AlamofireAsync

Async extension for Alamofire
Swift
3
star
19

DongerListKeyboard

Experimenting with iOS 8 keyboard in swift
Objective-C
3
star
20

JSTester

A simple structure tester for javascript programs.
JavaScript
1
star
21

librarymanagement

Python
1
star
22

frappe_app_template

1
star