TWRPickerSlider

https://github.com/chasseurmic/TWRPickerSlider

Usage

Add the dependency to your Podfile:

用 Podfile 添加依赖关系

platform :bios
pod 'TWRPickerSlider’, ‘~> 1.0’
...

Run pod install to install the dependencies.

运行 pod install 来安装依赖

Next, import the header file wherever you want to use the picker:

下一步,导入头文件

#import "TWRSliderStackedView.h"
#import "TWRPickerSlider.h"

You should first initialize your TWRPickerSlider as such:

你需要用以下的方式来初始化对象:

TWRPickerSlider *slider1 = [[TWRPickerSlider alloc] init];

…and assign some objects for the picker:

然后,你可以给 picker 赋值几个对象:

slider1.pickerObjects = @[obj1, obj2, obj3];

Objects passed to the picker can be of any type, provided they conform to the TWRPickerSliderDatasource protocol. Said protocol only requires the user to implement the following method, which returns the string that the picker will display for the object:

对象可以是任意类型,你只需要给TWRPickerSliderDatasource提供字符串数据即可:

- (NSString *)twr_pickerTitle;

Then set the picker delegate to be your view controller and implement theTWRPickerSliderDelegate protocol:

然后设置代理到你的控制器中,并实现协议:

// Set Delegate
slider1.delegate = self; // TWRPickerSliderDelegate
- (void)objectSelected:(id<TWRPickerSliderDatasource>)selectedObject sender:(TWRPickerSlider *)sender{
NSLog(@"Selected object: %@", [selectedObject twr_pickerTitle]);
}

Finally add you TWRPickerSlider instance to your view. It will automatically position itself at the bottom of the view and animate / slide when pressed.

最后添加 TWRPickerSlider 到你的view上,它会自动的将它自己添加到底端

Stacking pickers

Alternatively, if you have or want to display more than one picker at a time, you can instantiate a TWRSliderStackedView object and assign it an array of TWRPickerSlider.

另外,如果你想在同一时间显示超过一个的picker,你可以初始化TWRSliderStackedView对象,然后在它的数组对象中赋值TWRPickerSlider对象。

TWRSliderStackedView *stack = [[TWRSliderStackedView alloc] init];
stack.sliders = @[slider1, slider2, slider3];
[self.view addSubview:stack];

Again, the stacked view will position itself at the bottom of the current view. If you’re working inside a tab bar controller, or if you don’t want the stacked view to stick at the bottom of the view controller, you can use one of the following two methods:

这个 stacked view将会把它自己安置在当前view的底部,如果你是在Tab bar控制器中作业,或者说你不想让stacked view在这个控制器的底端,你可以用下面的方法来设置:

- (instancetype)initWithBottomPadding:(NSUInteger)padding;
- (instancetype)initWithTabBar;

See the demo project for more details.

你可以看demo了解更多。

Requirements

TWRPickerSlider requires iOS 7.x or greater.

TWRPickerSlider需要iOS7.x以上版本

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

  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. Redis快照持久化

    Redis的持久化功能: redis为了内部数据的安全考虑,会把本身的数据以文件的形式保存到硬盘中一份,在服务器重启之后会自动把硬盘的数据恢复到内存(redis)里边. 数据保存到硬盘的过程就被称为” ...

  2. 虚拟机实现finally语句块

    1.ret.jsr.jsr_w与returnAddress指令实现finally语句块 当class文件的版本号等于或高于51.0,jsr和jsr_w这两个操作码也不能出现在code数组中. 所有re ...

  3. python-Condition 进程同步互斥

    #!/usr/bin/python import multiprocessing,time def A(cond): name=multiprocessing.current_process().na ...

  4. 基础爬虫,谁学谁会,用requests、正则表达式爬取豆瓣Top250电影数据!

    爬取豆瓣Top250电影的评分.海报.影评等数据!   本项目是爬虫中最基础的,最简单的一例: 后面会有利用爬虫框架来完成更高级.自动化的爬虫程序.   此项目过程是运用requests请求库来获取h ...

  5. java调用c/c++代码简单实现以及遇见的坑

    以下内容均来自互联网,感谢你们的分享,我只是使用的时候看这方便,可以称呼我“搬运工” 如有不合适的地方请与我联系,我会及时改正 首先你可能会遇见以下错误 第一个错误是你在vs编译器没有选择使用rele ...

  6. 每天一道leetcode141-环形链表

    考试结束,班级平均分只拿到了年级第二,班主任于是问道:大家都知道世界第一高峰珠穆朗玛峰,有人知道世界第二高峰是什么吗?正当班主任要继续发话,只听到角落默默想起来一个声音:”乔戈里峰” 前言 2018. ...

  7. 八段代码彻底掌握 Promise

    1.Promise的立即执行性 var p = new Promise(function(resolve, reject){ console.log("create a promise&qu ...

  8. Java学习--扑克牌比大小的小游戏

    实现:生成五十四张牌,然后进行洗牌,输入两名玩家,然后分别发两张牌,进行比较大小,两张牌中拥有较大一张牌的玩家获胜 Card.java代码如下: package com.cardgame; publi ...

  9. js 数组常用的一些方法

    数组可以说是js经常会遇到的数据结构,以下我们对数组进行详细的学习! 一.数组的创建 var mycars = new Array(): || new Array(3);  || new Array( ...

  10. jsp技术知识点

    1.jsp被Tomcat翻译成.java文件后,会被放在Tomcat安装目录下的\work\Catalina\localhost\station\org\apache\jsp文件夹下 2.El表达式表 ...