UIAlertView first deprecated IOS 9

后端 未结 10 1300
南笙
南笙 2020-11-28 02:29

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 I

10条回答
  •  萌比男神i
    2020-11-28 02:51

    -(void)showAlert{
    
        UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Title"
                                                                       message:"Message"
                                                                preferredStyle:UIAlertControllerStyleAlert];
    
        UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                                              handler:^(UIAlertAction * action) {}];
    
        [alert addAction:defaultAction];
        [self presentViewController:alert animated:YES completion:nil];
    }
    

    [self showAlert]; // calling Method

提交回复
热议问题