博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[翻译] TWRPickerSlider
阅读量:6987 次
发布时间:2019-06-27

本文共 2508 字,大约阅读时间需要 8 分钟。

TWRPickerSlider

https://github.com/chasseurmic/TWRPickerSlider

Usage

Add the dependency to your Podfile:

用 Podfile 添加依赖关系

platform :biospod '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 Delegateslider1.delegate = self; // TWRPickerSliderDelegate - (void)objectSelected:(id
)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以上版本

 

转载地址:http://psmpl.baihongyu.com/

你可能感兴趣的文章
使用ulimit设置文件最大打开数
查看>>
[Step By Step]SAP HANA PAL指数回归预测分析Exponential Regression编程实例EXPREGRESSION(模型)...
查看>>
VMware Data Recovery备份恢复vmware虚拟机
查看>>
solr多core的处理
查看>>
解决DeferredResult 使用 @ResponseBody 注解返回中文乱码
查看>>
C# WinForm开发系列 - TextBox
查看>>
28岁少帅统领旷视南京研究院,LAMDA魏秀参专访
查看>>
java文件传输
查看>>
Xen虚拟机迁移技术
查看>>
安装Sql Server 2005出现“性能监视器计数器要求”错误解决方法。
查看>>
[.NET领域驱动设计实战系列]专题八:DDD案例:网上书店分布式消息队列和分布式缓存的实现...
查看>>
Icomparer和Icomparable集合排序
查看>>
【poi xlsx报错】使用POI创建xlsx无法打开
查看>>
UNIX环境高级编程笔记之文件I/O
查看>>
DIV+CSS规范命名
查看>>
我的2013 Q.E.D
查看>>
2017 Multi-University Training Contest - Team 9 1002&&HDU 6162 Ch’s gift【树链部分+线段树】...
查看>>
4.5. Rspamd
查看>>
ArcMap中的名称冲突问题
查看>>
(转) 一张图解AlphaGo原理及弱点
查看>>