日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[翻译] TWRPickerSlider

發布時間:2024/9/20 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [翻译] 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。