Multiple UIAlertControllers to show one after the other in Swift
OK, I've figured it out, what I've done is get the code to be ran when I press OK on the view , so that it checks the other sections then pops another one if need be.
I've putted it in after
action -> Void in
thanks a lot
How to pass multiple handlers in UIAlertAction
It's not totally clear what you're asking, but if you are trying to figure out which button was pressed so that you can execute different methods for each one you can do something like this:
@IBAction func buttonClicked(_ sender: UIButton) {
let alert = UIAlertController(title: "Select Value", message: nil, preferredStyle: .actionSheet)
for list in self.listValue {
alert.addAction(UIAlertAction(title: list.value, style: .default, handler: { (action) in
// How do I call different handlers here?
// I'll need to retrieve alert.title in these handlers
switch action.title {
case "Value A":
print("It's Value A")
case "Value B":
print("It's Value B")
default:
print("We didn't implement anything for this value")
}
}))
}
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel, handler: nil))
self.present(alert, animated: false, completion: nil)
}
Multiple lined UIAlertController message
It will work with \n
as edited.
let alert = UIAlertController(title: "Title",
message: "message: \n message",
preferredStyle: UIAlertControllerStyle.alert)
let cancelAction = UIAlertAction(title: "OK",
style: .cancel, handler: nil)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
Related Topics
Which Cgimagealphainfo Should We Use
How to Comment or Like a Photo in Facebook Through Fbconnect or Graph API in iPhone Sdk
How to Detect Tap on Clear Part of Uitableview
Gcd - Main VS Background Thread for Updating a Uiimageview
iOS App Getting Throttled from Local Searches
Xcode 7 Beta 6, Dyld _Nsarray0_ Crash
Open Viewcontroller from Tab Like in Instagram Camera Page on iOS
Cancel Button Is Not Shown in Uisearchbar
Create Directory in App Group Container Swift
Regex to Get String Between Two % Characters
Module Compiled with Swift 5.0.1 Cannot Be Imported by the Swift 5.1 Compiler
How to Accept/Decline Ekevent Invitation
How to Determine the Correct Altitude for an Mkmapcamera Focusing on an Mkpolygon