UIAlertView show() behavior for UIAlertController

前端 未结 4 1793
青春惊慌失措
青春惊慌失措 2020-12-17 04:55

In previous versions of iOS I was able to call show on a UIAlertView in the App Delegate. More specifically, show was called in:

fu         


        
4条回答
  •  春和景丽
    2020-12-17 05:13

    Try This

        UIAlertController * alert=   [UIAlertController
                                      alertControllerWithTitle:@"title"
                                      message:@" Your message hear"
                                      preferredStyle:UIAlertControllerStyleAlert];
    
        UIAlertAction *okBtnAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
            //Do what action u want.
            [alert dismissViewControllerAnimated:YES completion:nil];
        }];
        [alert addAction:okAction];
    
         UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
                [alert dismissViewControllerAnimated:YES completion:nil];
                //do something when click button
            }];
            [alert addAction:Action];
    
        UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
        [vc presentViewController:alert animated:YES completion:nil];
    

提交回复
热议问题