Questions tagged [uialertaction]

UIAlertAction object represents an action that can be taken when tapping a button in an alert. You use this class to configure information about a single action, including the title to display in the button, any styling information, and a handler to execute when the user taps the button. After creating an alert action object, add it to a UIAlertController object before displaying the corresponding alert to the user. Available in iOS 8.0 and later in UIKit.

A UIAlertAction object represents an action that can be taken when tapping a button in an alert. You use this class to configure information about a single action, including the title to display in the button, any styling information, and a handler to execute when the user taps the button. After creating an alert action object, add it to a UIAlertController object before displaying the corresponding alert to the user. Available in iOS 8.0 and later in UIKit. UIAlertAction

191 questions
47
votes
1 answer

Should self be captured as strong in a UIAlertAction's handler?

When writing the handler closure of a UIAlertAction, should the reference to self be strong (the default), weak, or unowned? There have been posts relevant to this topic (1, 2, 3, 4) but I honestly don't see how they help in this case. Let's focus…
Eric
  • 12,878
  • 13
  • 78
  • 119
20
votes
3 answers

Cancel Button in UIAlertController with UIAlertControllerStyle.ActionSheet

I want to add a separated cancel button to my UIAlert. I know how to do it with UIActionSheet but it should also be possible with UIAlert, right? var sheet: UIActionSheet = UIActionSheet(); let title: String = "..."; sheet.title = title; …
user4001326
17
votes
7 answers

How to edit UIAlertAction text font size and color

How to edit UIAlertAction text size and color? I have taken a UIAlertController acoording to it how to edit the size. This i smy Code UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Do you wish to logout?" message:@""…
naomi
  • 187
  • 1
  • 1
  • 9
16
votes
3 answers

UIAlertAction handler running after delay

I'm trying to change my UIAlertViews to UIAlertControllers. I set up this action for it: UIAlertAction *undoStopAction = [UIAlertAction actionWithTitle:@"Undo Stop" …
11
votes
2 answers

UIAlertController inconsistent position of buttons

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"hello" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *ok = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault…
Ted
  • 19,425
  • 10
  • 78
  • 99
10
votes
2 answers

UIAlertAction with different color button text

I am trying to create an UIAlertAction that has black color text for the first button and blue for the second. If I change the tint then all go black but i can't change the first button to black without it. Below is my code: let alert =…
user1079052
  • 3,395
  • 4
  • 24
  • 46
10
votes
4 answers

Trigger UIAlertAction on UIAlertController programmatically?

There are a couple of existing questions on this topic but they aren't quite what I'm after. I've written a little Swift app rating prompt for my app which presents two UIAlertController instances, one triggered by the other. I'm now trying to unit…
Luke
  • 8,709
  • 14
  • 74
  • 140
10
votes
3 answers

Select text in UIAlertController's text field

I need the text of the text field to be selected right after the UIAlertController is presented. However, the way I select text in a standard UITextField doesn't work here. This is what I tried, but I can't seem to get it work. let ac =…
Antonin Charvat
  • 869
  • 7
  • 16
10
votes
1 answer

Send Local Notifications while App is running in the background Swift 2.0

I am trying to send the user a 'Push Notification style' Alert when the user minimizes the app (by clicking on the iPhone's Home Button or by locking the phone as well). My app continuously parses an XML file (every 10 seconds) and I want the app…
Ivan
  • 480
  • 2
  • 9
  • 24
9
votes
4 answers

UIAlertAction handler is not called

I have a UITableView and in the delegate (view controller), I have implemented the function tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) I then test…
jpmcc
  • 338
  • 4
  • 9
8
votes
2 answers

UIAlertAction list of values

I'm trying to figure out how to change font type for UIAlertAction title. I'm assuming, it can be done by setting a value for particular key. For instance, to set an image you would do this: action.setValue(image, forKey: "image") Is there a list…
dmitryame
  • 478
  • 4
  • 17
7
votes
5 answers

Objective C - I would like UIAlertController to not be removed when button clicked

I would like to present a UIAlertController with 2 buttons. One button should close the alert and the second should perform an action but remain the alert on screen. Is there some configuration that can be done to action that it won't close the…
Luda
  • 9,237
  • 11
  • 67
  • 121
7
votes
5 answers

UIAlertAction Button Text Alignment Left

I want to align UIAlertAction text alignment to Left and add the icon as in image shown. I spent lot of time on google to get the solution but not found the right answer. Every body post for the alert title not for the alert action title. Please…
Ashu
  • 2,867
  • 29
  • 30
7
votes
1 answer

How do I pass more parameters to a UIAlertAction's handler?

Is there any way to pass the array "listINeed" to the handler function "handleConfirmPressed"? I was able to do this by adding it as a class variable but that seemed very hacky and now I want to do this for multiple variables so I need a better…
Max Crane
  • 97
  • 3
  • 7
6
votes
2 answers

In iOS UIAlertController, Can we left align text of UIAlertAction

I Need to implement a UIAlertController such as this UIAlertController with left alligned UIAlertAction After searching quite a lot in the internet and here in stackoverflow, I was able to achieve left aligned title of UIAlertController But how to…
Anand Reddy
  • 61
  • 1
  • 3
1
2 3
12 13