Premise:

Meet the following two conditions (refer to using this method)

    1. View popup using [[UIApplication sharedApplication] Delegate] window
    1. Use and pop up AlertController on this View

Phenomenon:

The pop-up AlertController layer is underneath the View layer, blocking the AlertController action

Principle:

  • 1. Create a ViewController object called tempVc;
  • 2. Add tempvc. view to the view to display AlertController.
  • 3. PresentViewController: animated: completion:

Implementation:

UIAlertController * alvc = [UIAlertController alertControllerWithTitle: @ "title" message: nil preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * confirmAction = [UIAlertAction actionWithTitle: @ "retry" style: UIAlertActionStyleDefault Handler :^(UIAlertAction * _Nonnull Action) {NSLog(@" callback method ----- KKKK ");}]; [alvc addAction:confirmAction]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle: @ "hang up" style: (UIAlertActionStyleDestructive) Handler :^(UIAlertAction * _Nonnull Action) {NSLog(@" callback method ----- KKKK ");}]; [alvc addAction:cancelAction]; UIViewController *tempVc = [[UIViewController alloc] init]; [self addSubview:tempVc.view]; [tempVc presentViewController:alvc animated:YES completion:^{ [tempVc.view removeFromSuperview]; }];Copy the code

___________ do not spray __________ if you do not like