pod 'ActionSheetPicker', '~> 1.0.5'
这就是它起始于的地方。现在,以下内容更为准确
ActionSheetPicker https://github.com/TimCinel/ActionSheetPicker
轻松地使用PickerView来展示ActionSheet,允许用户从一系列不可变选项中选择。基于在MobileSafari中找到的HTML下拉选项。
欢迎提出改进意见 - 我们会非常感谢 :)
有4种不同的Picker View选项:ActionSheetStringPicker
,ActionSheetDistancePicker
,ActionSheetDatePicker
和 ActionSheetCustomPicker
。我们将关注如何使用 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
感谢所有贡献者为iOS开发者社区使ActionSheetPicker变得更好。见AUTHORS获取详细信息。
John Garland (iPad!)
Greg Combs (重构!)
Petr Korolev (更新,错误修复,更新适用于iOS 7,新的选择器)