RNAlertController
@objcMembers
public final class RNAlertController : UIViewController
RNAlertController class
-
Initializes the alert
Declaration
Swift
public convenience init(title: String?, message: String?)
Parameters
title
Title for the alert
message
Message body of the alert
-
Declaration
Swift
public override func viewDidLoad()
-
Declaration
Swift
public override func viewDidAppear(_ animated: Bool)
-
Declaration
Swift
public override func viewDidDisappear(_ animated: Bool)
-
Presents the alert on the specified View Controller
Use this method to present RNAlertController alert on a specific view controller
Declaration
Swift
func present(on viewController: UIViewController, completion: (() -> Void)? = nil)
Parameters
viewController
UIViewController where the alert is to be presented
completion
Block to run after presenting the alert
-
Presents the alert
This method can be used without any view controller reference
Declaration
Swift
func show(completion: (() -> Void)? = nil)
Parameters
completion
Block to run after presenting the alert
-
Adds a button to the alert
Declaration
Swift
@discardableResult func addButton(title: String, type: AlertButtonType = .default, action: AlertAction? = nil) -> RNAlertController
Parameters
title
Title for the button
type
Choose
.normal
for regular button,.cancel
for bold button,.destructive
for red buttonaction
Block to run when the button is pressed (i.e. touchUpInside: action)
Return Value
RNAlertController instance
-
Adds an OK button to the alert
Declaration
Swift
@discardableResult func addOkButton(action: AlertAction? = nil) -> RNAlertController
Parameters
action
Block to run when the button is pressed (i.e. touchUpInside: action)
Return Value
RNAlertController instance
-
Adds a Cancel button to the alert
Declaration
Swift
@discardableResult func addCancelButton(action: AlertAction? = nil) -> RNAlertController
Parameters
action
Block to run when the button is pressed (i.e. touchUpInside: action)
Return Value
RNAlertController instance
-
Sets image for the alert
Multiple calls of this method will result in replacement of previously set image
Declaration
Swift
@discardableResult func setBannerImage(_ image: UIImage) -> RNAlertController
Parameters
image
image to use in the alert
Return Value
RNAlertController instance
-
Sets picker view data for the alert
Multiple calls of this method will result in replacement of previously set picker data
Declaration
Swift
@discardableResult func setPickerData(items: [String], selectedRow: Int = 0, selectionAction: AlertPickerAction?) -> RNAlertController
Parameters
items
An array of String to represent picker data collection
selectedRow
Row to be selected, defaults to 0 (zero) indicating the first item in the collection
selectionAction
Block to execute when an item is selected
Return Value
RNAlertController instance
-
Sets a button with URL
Declaration
Swift
@discardableResult func setURL(urlString: String, text: String) -> RNAlertController
Parameters
urlString
String representation of the URL
text
Placeholder for the URL
Return Value
RNAlertController instance