I want to display an alert. But as uialertView is deprecated for iOS 8, what can I do to display the alert for both kind of OS?
            Asked
            
        
        
            Active
            
        
            Viewed 152 times
        
    0
            
            
        - 
                    possible duplicate of [Showing alert with iOS7, iOS8 both](http://stackoverflow.com/questions/26229587/showing-alert-with-ios7-ios8-both) – gsanllorente Oct 13 '14 at 21:32
- 
                    Is duplicated... That it is what I was looking for. Thank you! – abonos App Oct 24 '14 at 08:33
1 Answers
1
            
            
        Try this code snippet to display the alert view in iOS8.This will definitely work.
- (IBAction)btn1Clicked:(UIButton *)sender {
// Alert style
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"ALERT!" message:@"What will you do?" preferredStyle:UIAlertControllerStyleAlert];
__weak ViewController *wself = self;
// Make choices for the user using alert actions.
**UIAlertAction** *doSomethingAction = [UIAlertAction actionWithTitle:@"I'm doing something" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
    __strong ViewController *sself = wself;
    sself.alertResponseLabel.text = @"You did something!";
}];
 UIAlertAction *doNothingAction = [UIAlertAction actionWithTitle:@"I'm totally ignoring this" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    __strong ViewController *sself = wself;
    sself.alertResponseLabel.text = @"OK, just ignore me...";
}];
// Add actions to the controller so they will appear
[**alert addAction:doSomethingAction];
[alert addAction:doNothingAction];**
 alert.view.tintColor = [UIColor blackColor];
**[self presentViewController:alert animated:YES completion:nil];**  }
 
    
    
        Alen Alexander
        
- 725
- 6
- 22
 
    