Questions tagged [uialertcontroller]

An iOS class, for displaying alerts and popup style selectors. Note that the legacy `UIActionSheet` and `UIAlertView` tags would not generally be used now.

In iOS, UIAlertController displays an alert message to the user, or, an action selector. (On iPhone, it's the large selector which appears from the bottom of the screen, usually with two or three choices.)

After configuration, it is presented using UIViewController.present. In the action sheet case, actions are added using UIAlertController.addAction.

This class replaced the older UIActionSheet and UIAlertView.

Apple UIAlertController Documentation

1683 questions
19
votes
2 answers

How to add actions to UIAlertController and get result of actions (Swift)

I want to set up a UIAlertController with four action buttons, and the titles of the buttons to be set to "hearts", "spades", "diamonds", and "clubs". When a button is pressed, I want to return its title. In short, here is my plan: // TODO: Create…
Abhi V
  • 714
  • 1
  • 4
  • 19
19
votes
2 answers

Leaks with UIAlertController

I added UIAlertController in my app by creating a category on UIViewController with the following method: - (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message actions:(NSArray…
MartinMoizard
  • 6,600
  • 12
  • 45
  • 75
19
votes
2 answers

UIPopover How do I make a popover with buttons like this?

I'm wondering how I can create a popover with buttons like this. ANSWER: UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: nil delegate: self …
ManOx
  • 1,935
  • 5
  • 23
  • 37
18
votes
6 answers

UIAlertController Not Working with Swift 3.0

I have the following alert method. static func notifyUser(_ title: String, message: String) -> Void { let alert = UIAlertController(title: title, message: message, …
BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156
18
votes
8 answers

Change the color of cancel button in UIAlertController with preferredStyle: .ActionSheet

Is it possible to change the color of cancel button to red , i know we can by using Destructive style let cancelActionButton: UIAlertAction = UIAlertAction(title: "Cancel", style: .Destructive) { action -> Void in print("Cancel") …
bikram sapkota
  • 1,106
  • 1
  • 13
  • 18
17
votes
7 answers

Alternative to UIAlertView for iOS 9?

UAlertView is deprecated in iOS 9 and later. What would be an alternative? UIAlertView *new = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Your InApp Purchases were successfully restored" delegate:nil cancelButtonTitle:@"OK"…
user3138007
  • 637
  • 1
  • 6
  • 19
17
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" …
17
votes
2 answers

How do I access the input from my text field in UIAlertController with objective c?

I'm changing everything over from AlertView to AlertController, but I can't find anything online for objective c that retrieves what the user inputs in a text field for the AlertController. Here is what I have: if ([UIAlertController class]) { …
Allison
  • 171
  • 1
  • 1
  • 6
17
votes
4 answers

Customize UIAlertController in iOS 8 to include standard elements like UITableView

I am used to customize UIAlertViews through the [alert setValue:someView forKey:@"accessoryView"] method. This creates customizable content for UIAlertViews with custom heights. However it only works on iOS7 and down. In iOS8 the UIAlertController…
kbjeppesen
  • 335
  • 1
  • 3
  • 9
16
votes
4 answers

Show UIAlertController over keyboard

In iOS 8 and lower show a UIActionSheet when keyboard is presented will present the action sheet over the keyboard. With iOS 9 this is no longer the case. In my app we have a chat functionality and want the show a action over the keyboard. We used…
rckoenes
  • 69,092
  • 8
  • 134
  • 166
16
votes
4 answers

show UIAlertController outside of ViewController

I have trouble to display my UIAlertController because I'm trying to show it in a Class which is not an ViewController. I already tried adding it: var alertController = UIAlertController(title: "Title", message: "Message", preferredStyle:…
Michael
  • 1,030
  • 14
  • 29
16
votes
1 answer

ActionSheet Source View BarButtonItem

I have a bar button item in the navigation bar that when pressed, will present a UIAlertController with the style as .ActionSheet. In the iPhone it appears just the way that I want. For the iPad I know I need to add // For iPad, set the pop over…
Mike Walker
  • 2,944
  • 8
  • 30
  • 62
16
votes
12 answers

iOS 8.3 UIAlertController crashes when trying to add a textfield

I have an iPad app. I am creating an UIAlertController and adding a textfield. It crashes. It only crashes when I add a textfield. let alert = UIAlertController(title: "Enter Name", message:nil, preferredStyle: UIAlertControllerStyle.Alert); …
MweyaMutsvene
  • 543
  • 4
  • 15
16
votes
6 answers

UIAlertController with text field - hitting return button only hides keyboard, does not perform action?

I'm trying to use the iOS 8 UIAlertController in place of where I would have used a UIAlertView in the past. I want the user to be able to enter text into this alert and hit "OK" to process the text or "Cancel" to cancel. Here's the basic…
UberJason
  • 3,063
  • 2
  • 25
  • 50
16
votes
10 answers

Concurrent UIAlertControllers

I'm porting my app to iOS 8.0 and notice that UIAlertView is deprecated. So I've changed things to use a UIAlertController. Which works in most circumstances. Except, when my app opens, it does several checks to report various states back to the…
Fittoburst
  • 2,215
  • 2
  • 21
  • 33