1

UIAlertController が self.view addSubView メソッドを介して表示されるときに、View Controller に UIBlurEffect を実装しました。ただし、アラート コントローラーを閉じたアクション コードでは、ぼかし効果が削除されるまでに数秒の遅延がかかります。遅延の理由は何かありますか?

// Create effect
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
// Add effect to an effect view
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = self.view.frame;

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Input Required" message:@"You are using UIAlertController" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancel = nil;

if(self.m_txtStaffID.text.length == 0)
{
    // Add the effect!
    [self.view addSubview:visualEffectView];

    cancel = [UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action)
              {
                  [self.m_txtStaffID becomeFirstResponder];
                  [visualEffectView removeFromSuperview]; // this takes a full 1-2 seconds to take effect
                  [alert dismissViewControllerAnimated:YES completion:nil]; // but this is almost immediately!
              }];
    [alert addAction:cancel];

    alert.message = @"Enter your staff ID and try again";
    [self presentViewController:alert animated:YES completion:nil];
    return;
}
4

0 に答える 0