警告框

 UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Title"  
                                                                   message:@"This is an alert."  
                                                            preferredStyle:UIAlertControllerStyleAlert];  
      
    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault  
                                                          handler:^(UIAlertAction * action) {  
                                                              //响应事件  
                                                              NSLog(@"action = %@", action);  
                                                          }];  
    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault  
                                                          handler:^(UIAlertAction * action) {  
                                                              //响应事件  
                                                              NSLog(@"action = %@", action);  
                                                          }];  
  
    [alert addAction:defaultAction];  
    [alert addAction:cancelAction];  
    [self presentViewController:alert animated:YES completion:nil];  

你可能感兴趣的:(警告框)