ActionSheetPicker 1.6.2

ActionSheetPicker 1.6.2

测试已测试
语言语言 Obj-CObjective C
许可 BSD
发布上次发布2015年7月

skywinder维护。



  • 作者
  • Tim Cinel, Filote Stefan, Brett Gibson, John Garland, Mark van den Broek, Evan Cordell, Greg Combs, Hari Karam Singh 和 Petr Korolev

pod 'ActionSheetPicker', '~> 1.0.5'

ActionSheetPicker = UIPickerView + UIActionSheet

这就是它起始于的地方。现在,以下内容更为准确

  • iPhone/iPod ActionSheetPicker = A Picker + UIActionSheet
  • iPad ActionSheetPicker = A Picker + UIPopoverController

概述

ActionSheetPicker https://github.com/TimCinel/ActionSheetPicker

轻松地使用PickerView来展示ActionSheet,允许用户从一系列不可变选项中选择。基于在MobileSafari中找到的HTML下拉选项。

欢迎提出改进意见 - 我们会非常感谢 :)

优势

  • 通过便利函数创建选择器 - 无需代理或引用。只需要提供目标/动作回调。
  • 向UIToolbar添加按钮以快速选择(见下方的ActionSheetDatePicker)
  • 提供代理协议以进行更多控制
  • 通用(iPhone/iPod/iPad)

快速入门

有4种不同的Picker View选项:ActionSheetStringPickerActionSheetDistancePickerActionSheetDatePickerActionSheetCustomPicker。我们将关注如何使用 ActionSheetStringPicker,因为它很可能是您想使用的。

基本使用

// Inside a IBAction method:

// Create an array of strings you want to show in the picker:
NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", @"Orange", nil];

[ActionSheetStringPicker showPickerWithTitle:@"Select a Color"
                                        rows:colors
                            initialSelection:0
                                   doneBlock:nil
                                 cancelBlock:nil
                                      origin:sender];

但是,你可能想知道当发生某些事情时怎么办,对吧?

// Inside a IBAction method:

// Create an array of strings you want to show in the picker:
NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", @"Orange", nil];

[ActionSheetStringPicker showPickerWithTitle:@"Select a Color"
                                        rows:colors
                            initialSelection:0
                                   doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
                                      NSLog(@"Picker: %@", picker);
                                      NSLog(@"Selected Index: %@", selectedIndex);
                                      NSLog(@"Selected Value: %@", selectedValue);
                                    }
                                 cancelBlock:^(ActionSheetStringPicker *picker) {
                                      NSLog(@"Block Picker Canceled");
                                    }
                                      origin:sender];
// You can also use self.view if you don't have a sender

屏幕截图

ActionSheetPicker ActionSheetDatePicker ActionSheetDistancePicker iPad Support

鸣谢

感谢所有贡献者为iOS开发者社区使ActionSheetPicker变得更好。见AUTHORS获取详细信息。

贡献者

Filote Stefan

Brett Gibson

John Garland (iPad!)

Mark van den Broek

Evan Cordell

Greg Combs (重构!)

Petr Korolev (更新,错误修复,更新适用于iOS 7,新的选择器)

创建者

Tim Cinel

@TimCinel

timcinel.com/