RNAlertController
@objcMembers
public final class RNAlertController : UIViewController
An object that provides RNAlertController.
-
Initializes the alert.
Declaration
Swift
public convenience init(title: String?, message: String?)Parameters
titleTitle for the alert.
messageMessage body of the alert.
-
Declaration
Swift
public override func viewDidLoad() -
Declaration
Swift
public override func viewDidAppear(_ animated: Bool) -
Declaration
Swift
public override func viewWillDisappear(_ animated: Bool) -
Declaration
Swift
public override func viewDidDisappear(_ animated: Bool) -
Declaration
Swift
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
-
Initializes the alert.
Declaration
Swift
static func alertController(title: String?, message: String?) -> RNAlertControllerParameters
titleTitle for the alert.
messageMessage body of the alert.
Return Value
RNAlertControllerinstance.
-
Presents the alert on the specified view controller.
Use this method to present
RNAlertControlleralert on a specific view controller.Declaration
Swift
func present(on viewController: UIViewController, completion: (() -> Void)? = nil)Parameters
viewControllerUIViewControllerwhere the alert is to be presented.completionBlock to run after presenting the alert.
-
Presents the alert on its own window.
Declaration
Swift
func present(_ completion: (() -> Void)? = nil)Parameters
completionBlock to run after presenting the alert.
-
Dismisses the alert.
Declaration
Swift
func dismiss(_ completion: (() -> Void)? = nil)Parameters
completionBlock to run after dismissing the alert.
-
Adds a button to the alert.
Declaration
Swift
@discardableResult func addButton(title: String, type: AlertButtonType = .default, action: AlertAction? = nil) -> RNAlertControllerParameters
titleTitle for the button.
typeButton style for the alert.
actionBlock to run when the button is pressed (i.e. touchUpInside: action).
Return Value
RNAlertControllerinstance. -
Adds an OK button to the alert.
Declaration
Swift
@discardableResult func addOkButton(action: AlertAction? = nil) -> RNAlertControllerParameters
actionBlock to run when the button is pressed (i.e. touchUpInside event).
Return Value
RNAlertControllerinstance. -
Adds a Cancel button to the alert.
Declaration
Swift
@discardableResult func addCancelButton(action: AlertAction? = nil) -> RNAlertControllerParameters
actionBlock to run when the button is pressed (i.e. touchUpInside event).
Return Value
RNAlertControllerinstance. -
Sets attributed text for the message.
When set, message text will use attributed text instead of regular text.
Declaration
Swift
@discardableResult func setAttributedMessageText(_ attributedText: NSAttributedString?) -> RNAlertControllerParameters
attributedTextAttributed string to set.
-
Sets the banner image for the alert.
Banner image is displayed under the message body or at the very top of the body. Consequent calls of this method will result in replacement of previously set image.
Declaration
Swift
@discardableResult func setBannerImage(_ image: UIImage, position: AlertBannerPosition = .afterBody) -> RNAlertControllerParameters
imageimage to use in the alert.
positiondetermines the position of the image.
Return Value
RNAlertController` instance.
-
Sets picker view data for the alert.
Note
Consequent 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?) -> RNAlertControllerParameters
itemsAn array of
Stringto represent picker data collection.selectedRowRow to be selected. The default value is 0 (zero) indicating the first item in the collection.
selectionActionBlock to execute when an item is selected.
Return Value
RNAlertControllerinstance. -
Sets a button with an URL.
A button is placed under the message body. Consequent calls of this method will result in replacement of previously set URL.
Declaration
Swift
@discardableResult func setURL(urlString: String, text: String? = nil) -> RNAlertControllerParameters
urlStringStringrepresentation of the URL.textPlaceholder for the URL. If
nilis passed, original URL will be used.Return Value
RNAlertControllerinstance. -
Sets a date picker with a selected date.
A date picker is placed under the message body.
Declaration
Swift
@discardableResult func setDatePicker(mode: UIDatePicker.Mode, selectedDate: Date? = nil, maximumDate: Date? = nil, minimumDate: Date? = nil, selectionAction: AlertDatePickerAction? = nil) -> RNAlertControllerParameters
modeUIDatePicker.Modedescribing the mode displayed the date picker.selectedDateDateto set. If passednil, current date is used.maximumDateMaximum date that a date picker can show.
minimumDateMinimum date that a date picker can show.
selectionActionBlock to execute when date is selected.
Return Value
RNAlertControllerinstance. -
Sets a checkbox with a title below the message body.
Declaration
Swift
@discardableResult func setCheckboxView(title: String?, isSelected: Bool, action: AlertCheckboxAction?) -> RNAlertControllerParameters
titleA message that is shown on the right of the checkbox.
isSelectedBoolean value indicating the primary state of the checkbox.
actionBlock to execute the checkbox is toggled.
Return Value
RNAlertControllerinstance.
View on GitHub
RNAlertController Class Reference