ZLSwipeableView

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

一个简单的view,效果类似于卡牌,ZLSwipeableView最初是用于Murmur应用的开发.

Preview

Swipe

Swipe Cancel

Swipe Programmatically

CocoaPods - 用CocoaPods安装

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

你可以通过CocoaPods来安装这个文件:

pod 'ZLSwipeableView'

Usage - 使用

Check out the demo app for an example.

你可以在示例中查看使用方法.

ZLSwipeableView can be added to storyboard or instantiated programmatically:

ZLSwipebleView可以直接在storyboard中使用或者是直接实例化出来:

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

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

ZLSwipeableView必须有一个对象,这个对象是作为data source来使用的.

// 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.

ZLSwipeableView can have an optional delegate to receive callback.

demo中已经包含了通过Xib和普通模式创建出来view的例子,ZLSwipeableView能够通过可选的协议来接受回调.

// optional delegate
self.swipeableView.delegate = self; #pragma mark - ZLSwipeableViewDelegate
- (void)swipeableView:(ZLSwipeableView *)swipeableView didSwipeLeft:(UIView *)view {
NSLog(@"did swipe left");
}
- (void)swipeableView:(ZLSwipeableView *)swipeableView didSwipeRight:(UIView *)view {
NSLog(@"did swipe right");
}
- (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:

滑动顶部的view:

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

To discard all views and reload programmatically:

弃用所有的view,然后重新加载:

[self.swipeableView discardAllSwipeableViews];
[self.swipeableView loadNextSwipeableViewsIfNeeded];

Requirements - 需要的环境

  • iOS 7 or higher. iOS7及以上
  • Automatic Reference Counting (ARC). ARC

Credits

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

[翻译] ZLSwipeableView的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. JVM-垃圾收集过程的内存管理

    JDK1.7 JVM的垃圾收集算法有 1. 标记-清除算法: 2. 复制算法:在商业虚拟机都是使用这种算法来回收新生代的 3. 标记-整理算法: 4.分代收集算法: JDK1.7 JVM的垃圾收集器有 ...

  2. 创建自己的区块链游戏SLOT——以太坊代币(三)

    一个以太坊合约版本的轮盘游戏,向合约转账ETH,有几率获得3,5,10,100倍奖励 合约地址:0x53DA598E70a1505Ad95cBF17fc5DCA0d2c51174b 捐赠ETH地址:0 ...

  3. goahead3.6.3就基本使用(后台上传信息到html页面),高手请忽略

    声明:这里面的代码均为网上找的然后有小小的改动,并非原创.但文章为原创 一..编译 1.1,.下载:进入http://embedthis.com/goahead/下载goahead3.6.3(2017 ...

  4. 使用ehCache作为本地缓存

    package nd.sdp.basic.config; import org.springframework.cache.CacheManager; import org.springframewo ...

  5. 搭建nginx代理,为前端页面跨域调用接口

    前端同学因开发需要,本地搭建的服务需要调用其它域名的接口,在帮助正确配置后,已能正常使用. 这里写一篇博客,记录一下. 前端页面地址为127.0.0.1:9813/a.html 接口地址http:// ...

  6. RestTemplate的一个请求过程,mark一下

    来看下RestTemplate中默认的的ResponseErrorHandler: package org.springframework.web.client; import java.io.IOE ...

  7. SQL 之获取DATE类的年月日语句

    Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM Select CONVERT(varchar(100), GETDATE( ...

  8. java 基础 --- servlet

    问题 : servlet 这个类是有什么作用 概述 servlet 是个接口,这个接口的作用是规范了接收请求的处理类.而最终的实现交给了 servlet 容器去实现. servlet 接口 接口方法如 ...

  9. Axios的详细配置和相关使用

    Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中. Features 从浏览器中创建 XMLHttpRequests 从 node.js 创建 http  ...

  10. shortcut icon和icon代码的区别介绍

    语句一: <link rel="shortcut icon" href="favicon.ico" /> 语句二: <link rel=&qu ...