[翻译] ZLSwipeableView
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];
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.
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.
A 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的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- android studio2.3.3 模拟器 Jni函数调用C++对象,lldb调试this指针和相关变量显示无效的原因
android studio2.3.3 的版本中 Jni函数调用C++对象,对象调用相关的成员函数, lldb调试,变量跟踪窗口,this指针和相关变量显示无效的原因,但这些参数实际是有效的,只是de ...
- struts2上传单个文件
项目目录: struts.xml配置: <constant name="struts.enable.DynamicMethodInvocation" value=" ...
- git stash使用一则
当在新的分支工作,修改的文件提交到暂存区,这时,切换到其他分之,可能报错,因为米有commit,如果切换到其他分支,暂存区的修改可能丢失,我们可以使用git stash save -a(暂存区) &q ...
- cppjieba分词学习笔记
cppjieba分词包主要提供中文分词.关键词提取.词性标注三种功能 一.分词 cppjieba分词用的方法是最大概率分词(MP)和隐马尔科夫模型(HMM),以及将MP和HMM结合成的MixSegme ...
- 【LeetCode题解】530_二分搜索树的最小绝对值差
目录 [LeetCode题解]530_二分搜索树的最小绝对值差 描述 方法一.中序遍历二分搜索树 思路 Java 代码 Python 代码 [LeetCode题解]530_二分搜索树的最小绝对值差 描 ...
- Android OpenGL教程-第六课【转】
第六课 纹理映射: 在这一课里,我将教会你如何把纹理映射到立方体的六个面. 激动的时刻来了,加载图片了. 复习一下android加载图片的知识.放一个png到drawable里面. (图片文件名:ne ...
- 激活 IntelliJ IDEA
1.点击下面的链接下载 JetbrainsIdesCrack-4.2-release.jar 链接:https://pan.baidu.com/s/1eNY_bwxF7Efl4QG0yh6l1A 提 ...
- Redis---1、介绍
Redis简介: 是以key-value形式存储,和传统的关系型数据库不一样,不一定遵循传统数据库的一些基本要求. 优点: 对数据高并发读写 对海量数据的高效率存储和访问 对数据的可扩展性和高可用行 ...
- 1、类、封装(私有private、this关键字)
类与对象 对象在需求中的使用 对面向对象有了了解之后,我们来说说在具体问题中如何使用面向对象去分析问题,和如何使用面向对象. 我们把大象装冰箱为例进行分析. 在针对具体的需求,可以使用名词 ...
- g2o error2
./pose_estimation_3d2d: error while loading shared libraries: libg2o_core.so: cannot open shared obj ...