测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最新版本 | 2017年10月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由 Pavel Pantus 维护。
如果你想与我一起玩耍,请点击这里 并享受!
尝试我的最简单方法(确保您首先阅读了需求部分)
pod try PPAssetsActionController
开始使用 PPAssetsActionController 非常简单。
请确保检查包含相当多用例的示例项目
您需要做的就是
import PPAssetsActionController
func presentAssetsActionController() {
let assetsPicker = PPAssetsActionController(with: [])
present(assetsPicker, animated: true, completion: nil)
}
如果您要显示一些选项,您会这样做
import PPAssetsActionController
func presentAssetsActionController() {
let options = [
PPOption(withTitle: option1String) { print("my option 1 callback") },
PPOption(withTitle: option2String) { print("my option 2 callback") }
]
let assetsPicker = PPAssetsActionController(with: options)
present(assetsPicker, animated: true, completion: nil)
}
如果您想了解 PPAssetsActionController 有什么要说,成为它的代理
import PPAssetsActionController
class CustomizationsViewController: UITableViewController {
func presentAssetsActionController() {
let options = [
PPOption(withTitle: option1String) { print("my option 1 callback") },
PPOption(withTitle: option2String) { print("my option 2 callback") }
]
let assetsPicker = PPAssetsActionController(with: options)
assetsPicker.delegate = self
present(assetsPicker, animated: true, completion: nil)
}
}
extension CustomizationsViewController: PPAssetsActionControllerDelegate {
/**
Callbacks implementations you're interested in.
*/
}
如果您想自定义 PPAssetsActionController 的外观或行为,请查看 PPAssetsActionConfig
结构体并像这样使用它
import PPAssetsActionController
func presentAssetsActionController() {
let options = [
PPOption(withTitle: option1String) { print("my option 1 callback") },
PPOption(withTitle: option2String) { print("my option 2 callback") }
]
var config = PPAssetsActionConfig()
config.tintColor = UIColor.magenta
let assetsPicker = PPAssetsActionController(with: options, aConfig: config)
present(assetsPicker, animated: true, completion: nil)
}
示例项目支持俄语语言的完整本地化,包括复数。
如果您想查看它,只需运行 PPAssetsActionController_Example_Rus
模式。
有关更多信息,我建议您查看这篇不错的教程,作者是 Quentin Zervaas。
这篇文章将让您迅速了解本地化的所有复杂性。
要运行示例项目,首先从仓库中克隆,然后从 Example 目录运行 pod install
。
PPAssetsActionController 通过 CocoaPods 提供。要安装,
只需将以下行添加到您的 Podfile 中
pod 'PPAssetsActionController'
PPAssetsActionController 也通过 Carthage 提供。
将以下行添加到您的 Cartfile 中
github "pantuspavel/PPAssetsActionController"
为了打开项目
git clone [email protected]:pantuspavel/PPAssetsActionController.git
cd PPAssetsActionController
bundle
cd Example
pod install
open PPAssetsActionController.xcworkspace
要运行自动化测试,您需要设置模拟器和加载资源。
cd PPAssetsActionController
./.setup_sim.sh "name=iPad Air 2,OS=10.1" // See setup_sim.sh to discover all supported simulators.
当脚本完成后,转到 Xcode 并选择刚刚创建的模拟器(iPad 版本的 assets-vs-ipad-ios10
)。
按 command+U,享受!
如果您在 iOS10 上使用 PPAssetsActionController,您需要在您的应用的应用程序 Info.plist 中声明 NSPhotoLibraryUsageDescription
、NSMicrophoneUsageDescription
和 NSCameraUsageDescription
键,否则您的应用将在启动时崩溃。例如,可以参考示例项目的 Info.plist。有关更多信息,请参阅这篇文章。
非常欢迎反馈。如果您有想法,不妨在推特上@pantusp联系我,或在这里留言。
非常欢迎并且鼓励贡献。如果您想表达观点,请提交issue或创建PR来开始对话。
Pavel Pantus, @pantusp, [email protected]
PPAssetsActionController 在MIT许可下可用。有关更多信息,请参阅LICENSE文件。