NRControls
更新
- 现在支持 Xcode 9+
- 添加浏览文件功能 - 文件选择器
简介
NRControls:这个类用于使用常见的控件,如警报、操作表和图像选择器控制器,并带有适当的完成处理程序。这意味着当您打开图像选择器控制器时,您不需要担心实现图像选择器控制器的代理,而是在完成处理程序中的同一行代码中获取您选择的照片。这个库主要包含五个方法,用于以下目的
- 图像选择器控制器
- AlertView
- 操作表
- 带有文本字段的 AlertView(例如,您可以用这个方法处理忘记密码的情况,以及其他很多情况。)
- 拍照或选择照片,使用上述方法,并利用完成处理程序在同一行代码中获取选定的图像。
- 文档选择器 - 您可以从本地或云端在您的应用中选择任何文档。
示例
要运行示例项目,首先克隆存储库,然后在 Example 目录中运行 pod install
。
要求
Xcode 9+ , Swift 4 , iOS 9 以及更高版本
安装
NRControls 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "NRControls"
使用方式
文件选择器
@IBAction func documentPickerButtonPressed(sender: UIButton) {
NRControls.sharedInstance.openDocumentPicker(self) { (urls) in
print(urls ?? "Cancelled")
}
}
拍照或选择照片
@IBAction func takeChoosePhoto(sender: UIButton) {
NRControls.sharedInstance.takeOrChoosePhoto(self) { (selectedImage) in
self.imageView.image = selectedImage
}
}
AlertView
@IBAction func alertViewButtonClicked(sender: UIButton) {
NRControls.sharedInstance.openAlertViewFromViewController(self, title: "Logout Alert", message: "Are you sure you want to logout?", buttonsTitlesArray: ["Cancel","Ok"]) { (alertController, index) in
print("index = \(index)")
}
}
操作表
@IBAction func actionSheetViewButtonClicked(sender: UIButton) {
NRControls.sharedInstance.openActionSheetFromViewController(self, title: "Action Sheet", message: "This is action sheet test message", buttonsTitlesArray: ["Login", "Logout"]) { (alertController, index) in
print("index = \(index)")
}
}
邮件编辑器
@IBAction func mailComposerButtonClicked(sender: UIButton) {
NRControls.sharedInstance.openMailComposerInViewController(["[email protected]"], viewcontroller: self) { (result, error) in
print(result)
}
}
带文本字段的AlertView
@IBAction func alertViewWithTextFieldButtonClicked(sender: UIButton) {
NRControls.sharedInstance.openAlertViewWithTextFieldFromViewController(self, title: "TextField demo", message: "This is textfield test", placeHolder: "Enter your email", isSecure: false, buttonsTitlesArray: ["Cancel","Submit"], isNumberKeyboard: false) { (alertController, index, text) in
print(text)
}
}
贡献
贡献总是受欢迎的!(
- 分支( http://github.com/naveenrana1309/NRControls/fork )
- 创建你的功能分支 ('git checkout -b my-new-feature')
- 提交你的更改 ('git commit -am 'Add some feature')
- 推到分支 ('git push origin my-new-feature')
- 创建新的拉取请求
兼容性
Xcode 9+ , Swift 4 , iOS 10 及以上
作者
Naveen Rana. 查看个人资料
Email: [email protected].
查看Facebook 个人资料了解更多详情。
许可证
NRControls可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。