2.JRAlertController里面会有一个属性是这样的:open var textFields: [UITextField]?。所有你添加的UITextField都会在这里。注意的是,JRAlertController已经对所以添加的UITextField进行了代理操作。如果你覆盖了代理,影响也不是很大,但是至少会影响你以下两点:
Open the new JRAlertController folder, and drag the JRAlertController.xcodeproj into the Project Navigator of your application’s Xcode project.
It should appear nested underneath your application’s blue project icon. Whether it is above or below all the other Xcode groups does not matter.
Select the JRAlertController.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the “Targets” heading in the sidebar.
In the tab bar at the top of that window, open the “General” panel.
Click on the + button under the “Embedded Binaries” section.
You will see two different JRAlertController.xcodeproj folders each with two different versions of the JRAlertController.framework nested inside a Products folder.
It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom JRAlertController.framework.
Select the top JRAlertController.framework for iOS.
And that’s it!
The JRAlertController.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
let alertController = JRAlertController(title: "blog tip", message: "Please select the option to use the corresponding option to operate your blog", preferredStyle: .actionSheet) // let alertController = JRAlertController(title: "blog tip") // let alertController = JRAlertController(message: "Please select the option to use the corresponding option to operate your blog") // let alertController = JRAlertController() let addAction = JRAlertAction(title: "add", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("add blog") }) let modifyAction = JRAlertAction(title: "modify", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("modify blog") }) let deleteAction = JRAlertAction(title: "delete", style: .destructive, handler: { (action: JRAlertAction!) -> Voidin print("delete blog") }) let cancelAction = JRAlertAction(title: "cancel", style: .cancel, handler: { (action: JRAlertAction!) -> Voidin print("cancel") }) alertController.addAction(addAction) alertController.addAction(modifyAction) alertController.addAction(deleteAction) alertController.addAction(cancelAction) // must use this function to show JRAlertController // self is a UIControllerView alertController.jr_show(onRootView: self)
let alertController = JRAlertController(title: "I am title,I am title,I am title,I am title,I am title", message: "I am message, I am message, I am message, I am message, I am message, I am message, I am message, I am message, I am message", preferredStyle: .actionSheet) let cancelAction = JRAlertAction(title: "cancel", style: .cancel, handler: nil) let deleteAction = JRAlertAction(title: "delete", style: .destructive, handler: nil) let archiveAction = JRAlertAction(title: "archive", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("archive") }) let archiveAction1 = JRAlertAction(title: "archive1", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("archive1") }) let archiveAction2 = JRAlertAction(title: "archive2", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("archive2") }) let archiveAction3 = JRAlertAction(title: "archive3", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("archive3") }) let archiveAction4 = JRAlertAction(title: "archive4", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("archive4") }) let archiveAction5 = JRAlertAction(title: "archive5", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("archive5") }) let archiveAction6 = JRAlertAction(title: "archive6", style: .default, handler: { (action: JRAlertAction!) -> Voidin print("archive6") }) alertController.addAction(cancelAction) alertController.addAction(deleteAction) alertController.addAction(archiveAction) alertController.addAction(archiveAction1) alertController.addAction(archiveAction2) alertController.addAction(archiveAction3) alertController.addAction(archiveAction4) alertController.addAction(archiveAction5) alertController.addAction(archiveAction6) // must use this function to show JRAlertController // self is a UIControllerView alertController.jr_show(onRootView: self)
License
JRAlertController is released under the Apache-2.0 license. See LICENSE for details.