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
41
votes
2 answers

Prevent UIAlertController to dismiss

I would like to prevent the UIAlertController from dismissing. I have a UIAlertAction that simply appends a string into the UIAlertTextField, however, once tapped it dismisses the view controller [undesired]. I've tried adding an NSNotification…
soulshined
  • 9,612
  • 5
  • 44
  • 79
39
votes
7 answers

UIAlertController:supportedInterfaceOrientations was invoked recursively

When two alert present one by one, i means one alert present and over them another alert presenting and app crashing. I have used UIAlertController to display alert. App crashing only in iOS 9 device. Please help me at this point.
Ashvin
  • 8,227
  • 3
  • 36
  • 53
37
votes
14 answers

How to change UIAlertController button text colour in iOS9?

The question is similar to iOS 8 UIActivityViewController and UIAlertController button text color uses window's tintColor but in iOS 9. I have a UIAlertController and the dismiss button keeps white colour even I have tried to set [[UIView…
RayChen
  • 1,417
  • 2
  • 17
  • 36
37
votes
8 answers

Show alert in AppDelegate in Swift

I try the next code snippet: var alert = UIAlertController(title: "Alert", message: "Cannot connect to : \(error!.localizedDescription)", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "Click", style:…
Orkhan Alizade
  • 7,379
  • 14
  • 40
  • 79
35
votes
8 answers

'UIAlertView' was deprecated in iOS 9.0. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead

I have see more so answers , but nothing helped.Here is my older alert and action for that override func viewWillAppear(animated: Bool) { if Reachability.isConnectedToNetwork() == true { print("internet connection ok") } else { …
user5513630
  • 1,709
  • 8
  • 24
  • 48
35
votes
7 answers

Present UIAlertController from AppDelegate

I'm trying to present a UIAlertController from the AppDelegate in my iOS app. Below is the alert and the present method. UIAlertController *alert = [UIAlertController alertControllerWithTitle:cTitle message:cMessage…
Satre
  • 1,724
  • 2
  • 18
  • 22
35
votes
8 answers

Showing a UIPickerView with UIActionSheet in iOS8 not working

Showing a UIPickerView with UIActionSheet in iOS8 not working The code works in iOS7, however it is not working in iOS8. I'm sure it is because UIActionSheet is deprecated in iOS8 and Apple recommends to use UIAlertController. However, how to do it…
34
votes
11 answers

UIAlertController tint color defaults to blue on highlight

I'm using the following code to present a UIAlertController action sheet with the item text as red. I've used the tint property to set the color. UIAlertController *alertController = [UIAlertController …
Bcf Ant
  • 1,639
  • 1
  • 16
  • 26
34
votes
10 answers

How to change the background color of the UIAlertController?

Due to strange behavior of UIActionSheet in iOS 8, I have implemented UIAlertController with UIAction as buttons in it. I would like to change the entire background of the UIAlertController. But I can't find any ways to do it. Tried even…
GJDK
  • 723
  • 2
  • 7
  • 19
33
votes
10 answers

Swift Displaying Alerts best practices

I have various controllers in my app that all require validation, and when validation fails, I want to display an alert with the errors. Is there some best practice/design pattern for doing this? I could simply create a static function in a Helper…
Ryan Bobrowski
  • 2,641
  • 3
  • 31
  • 52
31
votes
3 answers

how to use UIAlertController

I am trying to use this code in a Pacman game I got from some website but had to change UIAlertView to UIAlertController except the following code has two errors that I don't know how to fix (I am really new to programming and feel like this is a…
Howie Chowie
  • 329
  • 1
  • 3
  • 3
31
votes
12 answers

Is there any way to add UIPickerView into UIAlertController (Alert or ActionSheet) in Swift?

I'm totally new to swift (and iOS programming at all), but I started messing around with it (it wasn't a good idea when everything is still beta version :D). So I tried to figure it out by myself, but still nothing. Even tried to add subview…
Hristo Atanasov
  • 1,236
  • 2
  • 18
  • 25
30
votes
4 answers

Check on UIAlertController TextField for enabling the button

I have an AlertController with a text field and two button: CANCEL and SAVE. This is the code: @IBAction func addTherapy(sender: AnyObject) { let addAlertView = UIAlertController(title: "New Prescription", message: "Insert a name for this…
msalafia
  • 2,703
  • 5
  • 23
  • 34
28
votes
3 answers

UIAlertController handle dismiss upon click outside (IPad)

Previous to iOS8 we used the UIActionSheet for showing alert and now we need to use the UIAlertController. When we used the UIActionSheet we could easily handle situations where the user clicked outside the pop up (which means he want to cancel the…
Tomer Peled
  • 3,571
  • 5
  • 35
  • 57
27
votes
4 answers

IOS create UIAlertViewController programmatically

I'm working on a ViewController with code (no storyboard). I'm trying to add and AlertController I have declare propery in .m @property (nonatomic, strong) UIAlertController *alertController; And init in loadview method //alertviewController …
Lê Khánh Vinh
  • 2,591
  • 5
  • 31
  • 77