[翻译] TWRPickerSlider
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的更多相关文章
- 《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 ...
随机推荐
- 浅谈内存映射I/O(MMIO)与端口映射I/O(PMIO)的区别
最近在看NVMeDirect和SPDK的源码,觉得有必要梳理一下MMIO和PMIO的区别.关于MMIO和PMIO,维基百科上是这么讲滴, Memory-mapped I/O (MMIO) and po ...
- URL重写html后Html文件打不开解决办法
1.首先照旧在网站配置的应用程序扩展名映射中添加扩展名.html映射到aspnet_isapi.dll,是否存在不选: 2.在web.config文件中<compilation>节点下添加 ...
- vs2015 点击cshtml 后提示 "无效指针" 的解决办法
1. 关闭vs 2. 删除 %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache 3. 打开vs OK 解决
- Golang之并发资源竞争(读写锁)
前面的有篇文章在讲资源竞争的时候,提到了互斥锁.互斥锁的根本就是当一个goroutine访问的时候,其他goroutine都不能访问,这样肯定保证了资源的同步,避免了竞争,不过也降低了性能. 仔细剖析 ...
- 基于struts2注解@action的@Result跳转问题——跳转到另一个action
初学ssh 基于注解的方式简单灵活,但是做一个例子的时候,添加用户AddUser 完成后 想页面跳转到 ListUser 这个action, 然后action 成功后 会跳转到list.jsp 显示 ...
- MYSQL DATE_FORMAT() 函数时间大小比较
DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据. DATE_FORMAT(date,format) 可以使用的格式有: 格式 描述 %a 缩写星期名 %b 缩写月名 %c 月,数值 ...
- 撩课-Python-每天5道面试题-第1天
一. 尽可能详细的描述出一个应用软件, 比如QQ, 在计算机中运行时涉及的软硬件, 以及说明我们编程的侧重点? 电脑开机, 从硬盘中(外部存储设备)加载操作系统(系统软件)到内存(内部存储设备), 并 ...
- XML文档的解析—dom4j
XML为可扩展标记语言,它主要是用来保存数据,做配置文件,数据传输载体等.其实就是一个后缀名为.xml的文件. XML命名规则 名称可以含字母.数字以及其他的字符 名称不能以数字或者标点符号开始 名称 ...
- spring boot2 使用log4j2
spring boot默认使用的是logback,看到好多地方说logback比log4j耗性能,具体么我也没试过,不过个人还是log4j用得更多. 先看pom依赖 <dependency> ...
- oracle lpad rpad函数
学习并记录 1.情况一 ) from dual; 运行结果如下: email长度5,默认添加3个空格在左边 2.情况二 ) from dual; 运行结果如下: email长度5,截取2两个字符 3. ...