测试已测试 | ✓ |
语言语言 | Obj-CObjective C |
许可证 | BSD |
发布最新发布 | 2024 年 3 月 |
由 skywinder、ZWExt、NoorulAinAli 维护。
请欢迎:ActionSheetPicker-3.0!
pod 'ActionSheetPicker-3.0', '~> 2.3.0'
(iOS 5.1.1-9.x 兼容!)
##ActionSheetPicker = UIPickerView + UIActionSheet ##
就是这样开始的。现在,以下更为准确
轻松展示一个带有PickerView的ActionSheet,允许用户从多个不可变选项中进行选择。
有4种不同的picker view选项:ActionSheetStringPicker
、ActionSheetDistancePicker
、ActionSheetDatePicker
和ActionSheetCustomPicker
。我们将重点介绍如何使用ActionSheetStringPicker
,因为您可能最想使用它。
有关自定义的详细信息,请参阅基本使用
有关详细信息示例,请检查此仓库中的示例项目
Swift
ActionSheetMultipleStringPicker.show(withTitle: "Multiple String Picker", rows: [
["One", "Two", "A lot"],
["Many", "Many more", "Infinite"]
], initialSelection: [2, 2], doneBlock: {
picker, indexes, values in
print("values = \(values)")
print("indexes = \(indexes)")
print("picker = \(picker)")
return
}, cancel: { ActionMultipleStringCancelBlock in return }, origin: sender)
Objective-C
// 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: %@, Index: %@, value: %@",
picker, selectedIndex, selectedValue);
}
cancelBlock:^(ActionSheetStringPicker *picker) {
NSLog(@"Block Picker Canceled");
}
origin:sender];
// You can also use self.view if you don't have a sender
##安装##
CocoaPods是Cocoa项目的依赖管理器。
您可以使用以下命令安装它
$ gem install cocoapods
要使用CocoaPods将ActionSheetPicker-3.0集成到您的Xcode项目中,请在其Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod 'ActionSheetPicker-3.0'
然后,运行以下命令
$ pod install
要导入pod,您应该添加字符串
Obj-c
项目 #import "ActionSheetPicker.h"
Swift
项目 import ActionSheetPicker_3_0
Carthage是一个集中的依赖管理器,它自动化了将框架添加到您的Cocoa应用程序的过程。
您可以使用以下命令使用Homebrew安装Carthage
$ brew update
$ brew install carthage
要使用Carthage将ActionSheetPicker-3.0集成到您的Xcode项目中,请在其Cartfile
中指定它
github "skywinder/ActionSheetPicker-3.0"
如果您不希望使用上述任一依赖管理器,您可以手动将ActionSheetPicker-3.0集成到您的项目中。
“老式”的方法是手动将来自Pickers文件夹的所有内容添加到您的项目中。
cd
进入您的顶级项目目录,并执行以下命令将ActionSheetPicker-3.0作为子模块添加:$ git submodule add https://github.com/skywinder/ActionSheetPicker-3.0.git
ActionSheetPicker-3.0
文件夹,并将CoreActionSheetPicker.xcodeproj
拖入您的应用程序项目的文件导航器中。CoreActionSheetPicker.framework
。+
按钮,选择“New Copy Files Phase”,将此新阶段重命名为“Copy Frameworks”,将“Destination”设置为“Frameworks”,并添加CoreActionSheetPicker.framework
。打开ActionSheetPicker-3.0.xcworkspace
这里有4个项目
ActionSheetPicker
项目)open Example-for-and-6/ActionSheetPicker.xcodeproj
如果您已在实际应用程序中使用此项目,请告知我!看到别人对我的工作充满热情,是我最快乐的事情。
如果您正在您的应用程序中使用ActionSheetPicker-3.0
,或者知道使用它的应用程序,请将其添加到[此] (https://github.com/skywinder/ActionSheetPicker-3.0/wiki/Apps-using-ActionSheetPicker-3.0) 列表中。
ActionSheetPicker最初由Tim Cinel (@TimCinel) 创建。由于Tim的存储库不支持iOS 7+,我从他的存储库中分叉并实现了iOS 7-8的支持,以及大量UI修复、崩溃修复和不同的定制功能。
最重要的是,感谢ActionSheetPicker-3.0的贡献者列表不断增长。
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)欢迎提交bug报告、功能请求、补丁、祝福以及说唱演示磁带。