Advertisement
Guest User

BT UIAlertController Code

a guest
Sep 29th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //show alert
  2. -(void)showAlert:(NSString *)theTitle theMessage:(NSString *)theMessage alertTag:(int)alertTag {
  3.     /*
  4.      UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:theTitle message:theMessage delegate:self
  5.      cancelButtonTitle:NSLocalizedString(@"ok", "OK") otherButtonTitles:nil];
  6.      [alertView setTag:alertTag];
  7.      [alertView show];
  8.      */
  9.    
  10.    
  11.     UIAlertController * alertView = [UIAlertController
  12.                                      alertControllerWithTitle:theTitle
  13.                                      message:theMessage
  14.                                      preferredStyle:UIAlertControllerStyleAlert];
  15.    
  16.     UIAlertAction* yesButton = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  17.         //Handle your button action here
  18.         [self clickedOnButton:199];
  19.     }];
  20.    
  21.     UIAlertAction* noButton = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  22.         [self clickedOnButton:0];
  23.     }];
  24.    
  25.     [alertView addAction:yesButton];
  26.     [alertView addAction:noButton];
  27.     [self presentViewController:alertView animated:YES completion:nil];
  28.    
  29. }
  30. //
  31. -(void)clickedOnButton:(int)alertTag {
  32.     [BT_debugger showIt:self message:[NSString stringWithFormat:@"alertView clickedButtonAtIndex: %d", alertTag]];
  33.    
  34.    
  35.     if(alertTag == 0){
  36.         // [self.navigationController popViewControllerAnimated:YES];
  37.     }
  38.    
  39.    
  40.     if(alertTag == 199){
  41.         [self navLeftTap];
  42.     }
  43.    
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement