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" otherButtonTitles:nil];
[new show];

You can use this code to replace an alert view:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];           
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];

If you need multiple actions you can use:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" message:@"Message" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Button 1" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    // action 1
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Button 2" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    // action 2
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    [self dismissViewControllerAnimated:YES completion:nil];
}]];           
[self presentViewController:alertController animated:YES completion:nil];

Alternative to UIAlertView for iOS 9?, UAlertView is deprecated in iOS 9 and later. What would be an alternative? UIAlertView *new = [[UIAlertView alloc] initWithTitle:@ UIAlertView replacement iOS 9 379 Views 2 Replies. Latest reply on Oct 2, 2015 3:18 AM by strike . Level 1 (0 points) strike Oct 2 Content tagged with uialertview

You get often detailed information including the replacement suggestion by ⌘-clicking on the symbol which displays the class/method declaration.

In case of UIAlertView you will see

"UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"

UIAlertView, UAlertView is deprecated in iOS 9 and later. What would be an alternative? UIAlertView *new = [[UIAlertView alloc] initWithTitle:@"Success" message:@"​Your  warning: 'UIAlertView' is deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead Detecting the iOS version, and if is the 9+ use this new controller UIAlertController, if is old version use the UIAlertView.

  UIAlertController * alert=   [UIAlertController
                             alertControllerWithTitle:@"Info"
                             message:@"You are using UIAlertController"
                               preferredStyle:UIAlertControllerStyleAlert];

   UIAlertAction* ok = [UIAlertAction
                    actionWithTitle:@"OK"
                    style:UIAlertActionStyleDefault
                    handler:^(UIAlertAction * action)
                    {
                        [alert dismissViewControllerAnimated:YES completion:nil];

                    }];
  UIAlertAction* cancel = [UIAlertAction
                         actionWithTitle:@"Cancel"
                       style:UIAlertActionStyleDefault
                       handler:^(UIAlertAction * action)
                       {
                           [alert dismissViewControllerAnimated:YES completion:nil];
                        }];
 [alert addAction:ok];
 [alert addAction:cancel];

 [self presentViewController:alert animated:YES completion:nil];

objective c - UIAlertView first deprecated IOS 9, An alert view functions similar to but differs in appearance from an action sheet (​an instance of UIActionSheet ). SDKs. iOS 2.0–9.0Deprecated; Mac Catalyst  Yes/No Confirmation UIAlertView. Ask Question Asked 6 years, 7 months ago. Active 4 years, 1 month ago. UIAlertView is Deprecated from iOS 8.0 ,

UIAlertController has been around since iOS 8.

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​  Other answers already provide information for iOS 7 and older, however UIAlertView is deprecated in iOS 8. In iOS 8+ you should use UIAlertController. It is a replacement for both UIAlertView and UIActionSheet. Documentation: UIAlertController Class Reference. And a nice article on NSHipster. To create a simple Alert View you can do the following:

UIAlertController * alert=   [UIAlertController
                                    alertControllerWithTitle:@"My Title"
                                    message:@"Enter User Credentials"
                                    preferredStyle:UIAlertControllerStyleAlert];

    [self presentViewController:alert animated:YES completion:nil];

Programming iOS 4: Fundamentals of iPhone, iPad, and iPod touch , j'ai essayé plusieurs façons d'utiliser UIAlertController,au lieu de UIAlertView. Voici mon code qui fonctionne très bien dans IOS 8 et IOS 9 mais qui apparaît avec des drapeaux dépréciés. Consultez Alternative à UIAlertView pour iOS 9? This wrapper provides a way of converting UIAlertView to UIAlertController easily. UIAlertView is deprecated from iOS 9.0. Convert your UIAlertView of old projects to UIAlertController keeping your delegate implementation remain same using this UIAlertControllerWrapper and get rid of all the UIAlertView related warnings.

Programming IOS 5: Fundamentals of IPhone, IPad, and IPod Touch , Fundamentals of iPhone, iPad, and iPod touch Development Matt Neuburg For example, I type this: UIAlertView* av = [UIAlertView alloc I now type the right menu pops up, listing the four init methods appropriate to a UIAlertView (Figure 9​-2). of Esc. Pressing Control-Period re- peatedly cycles through the alternatives​. An alternative to the UIAlertView is the UIActionSheet. The application developer can use UIAlertViewStyle s such as PlainTextInput or LoginAndPasswordInput to allow the application user to enter values.

UIAlertView Class (UIKit), UIAlertView* av = [[UIAlertView alloc] init] [1 id inith'ithCoderHNSCoder *1 D id initI'i'ithFrame: ICGRGCLI El_ loltHlthTltIe:tNSStclag *1 mess Figure 9-2. instead of Esc. Pressing Control-Period repeatedly cycles through the alternatives. YRDropdownView is an iOS library for displaying stylish alerts, warnings, and errors UIKit’s Shortcomings From day one, iOS developers have been struggling to alert users about simple warnings and errors that may not interrupt the flow of the app. Popping up UIAlertViews requires the user to click a button to move along, which wasn’t quite

An alternative to the UIAlertView is the UIActionSheet. The application developer can use UIAlertViewStyles such as PlainTextInput or LoginAndPasswordInput to allow the application user to enter values. In apps that run in versions of iOS prior to iOS 8, use the UIAlert View class to display an alert message to the user. An alert view functions similar to but differs in appearance from an action sheet (an instance of UIAction Sheet).

Comments
  • Any reason you didn't simply looks at the docs for UIAlertView (which tells you exactly what to do) or do a search before posting this question? Please make some attempt to find an answer before posting.
  • if you don't find answer in their doc, better shift your project to iOS 8. :P
  • This takes so much code to implement... What are they thinking? The ability to handle responses without a delegate is a nice addition though.
  • @Kundapra Hudga, why did you choose to use dispatch_async for [self presentViewController:alertController animated:YES completion:nil]; ?
  • You are use the UIAlertController, See for Swift AlertController tutorial : iosdevcenters.blogspot.com/2016/03/…
  • Why presentViewController is called from dispatch queue?