Questions tagged [uialertview]

UIAlertView, a class contained in Apple's UIKit framework, was used to display an alert to the user. Alerts could have a title, message, several buttons, and custom subviews. UIAlertView was deprecated in iOS 8.

UIAlertView, a class contained in Apple's UIKit framework, was used to display an alert to the user. Alerts could have a title, message, several buttons, and custom subviews. UIAlertView was deprecated in iOS 8 and replaced with UIAlertController.

Use the properties and methods defined in this class to set the title, message, and delegate of an alert view and configure the buttons. You must set a delegate if you add custom buttons. The delegate should conform to the UIAlertViewDelegate protocol. Use the show method to display an alert view once it is configured.

Resources:

2558 questions
552
votes
36 answers

How would I create a UIAlertView in Swift?

I have been working to create a UIAlertView in Swift, but for some reason I can't get the statement right because I'm getting this error: Could not find an overload for 'init' that accepts the supplied arguments Here is how I have it…
BlueBear
  • 7,469
  • 6
  • 32
  • 47
127
votes
24 answers

UIAlertController custom font, size, color

I am using new UIAlertController for showing alerts. I have this code: // nil titles break alert interface on iOS 8.0, so we'll be using empty strings UIAlertController *alert = [UIAlertController alertControllerWithTitle: title == nil ? @"": title…
Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
119
votes
10 answers

UIAlertView first deprecated IOS 9

I have tried several ways to use UIAlertController,instead of UIAlertView. I tried several ways but I cannot make the alert action work. Here is my code that works fine in IOS 8 and IOS 9 but is showing up with deprecated flags. I tried the…
Bux
  • 1,273
  • 2
  • 9
  • 9
114
votes
10 answers

Writing handler for UIAlertAction

I'm presenting a UIAlertView to the user and I can't figure out how to write the handler. This is my attempt: let alert = UIAlertController(title: "Title", message: "Message", preferredStyle:…
Steve Marshall
  • 7,919
  • 4
  • 16
  • 17
111
votes
9 answers

Adding a simple UIAlertView

What is some starter code I could use to make a simple UIAlertView with one "OK" button on it?
Linuxmint
  • 4,716
  • 11
  • 44
  • 64
110
votes
4 answers

Create UIActionSheet 'otherButtons' by passing in array, not varlist

I have an array of strings that I want to use for button titles on a UIActionSheet. Unfortunately, the otherButtonTitles: argument in the method invocation takes a variable length list of strings, not an array. So how I can I pass these titles into…
Greg Maletic
  • 6,225
  • 8
  • 54
  • 73
75
votes
8 answers

Display UIViewController as Popup in iPhone

Since there is no complete, definitive answer to this common recurring question, I'll ask and answer it here. Often we need to present a UIViewController such that it doesn't cover full screen, as in the picture below. Apple provides several…
CRDave
  • 9,279
  • 5
  • 41
  • 59
67
votes
8 answers

UIAlertView addSubview in iOS7

Adding some controls to UIAlertView was deprecated in iOS7 using addSubview method. As I know Apple promised to add contentView property. iOS 7 is released now and I see that this property is not added. That is why I search for some custom solution…
B.S.
  • 21,660
  • 14
  • 87
  • 109
64
votes
11 answers

How to dismiss UIAlertController when tap outside the UIAlertController?

How to dismiss UIAlertController when tap outside the UIAlertController? I can add a UIAlertAction of style UIAlertActionStyleCancel to dismiss the UIAlertController. But I want to add the function that when user tap outside the UIAlertController…
leizh00701
  • 1,893
  • 5
  • 21
  • 32
64
votes
7 answers

Unable to add UITextField to UIAlertView on iOS7...works in iOS 6

The code below works on iOS6 (and before) but the UITextField does not display in iOS7...any ideas on how to get a UITextField to display in an UIAlterView in iOS7? UIAlertView* dialog = [[UIAlertView alloc] init]; [dialog setDelegate:self]; [dialog…
iTrout
  • 1,454
  • 2
  • 12
  • 21
57
votes
14 answers

UIAlertView/UIAlertController iOS 7 and iOS 8 compatibility

I am using Swift to write an app and I need to show an alert. The app must be iOS 7 and iOS 8 compatible. Since UIAlertView has been replaced with UIAlertController, how can I check if the UIAlertController is available without checking the system…
Shan
  • 3,057
  • 4
  • 21
  • 33
54
votes
17 answers

How to disable copy paste option from UITextField programmatically

I am making a registration alertview that has a UITextField in it where the user can enter their registration number. everything is pretty much their, however I would like to remove the copy paste function from the textfield programmatically since…
C.Johns
  • 10,185
  • 20
  • 102
  • 156
50
votes
10 answers

AlertController is not in the window hierarchy

I've just created a Single View Application project with ViewController class. I would like to show a UIAlertController from a function which is located inside my own class. Here is my class with an alert. class AlertController: UIViewController { …
wtznc
  • 895
  • 2
  • 14
  • 26
49
votes
10 answers

How to add a TextField to UIAlertView in Swift

I have this code, but I dont know how to show a textfield inside the UIAlertView. var altMessage = UIAlertController(title: "Warning", message: "This is Alert Message", preferredStyle:…
Apple Kid
  • 623
  • 2
  • 7
  • 16
48
votes
30 answers

NSLocalizedString only retrieves the key, not the value in Localizable.strings (IOS)

I've made a strings file named "Localizable.strings" and added two languages to it, like so: "CONNECTIONERROR" = "Check that you have a working internet connection."; "CONNECTIONERRORTITLE" = "Network error"; I have also converted the files to…
Smiden
  • 645
  • 1
  • 6
  • 11
1
2 3
99 100