当我的UIAlertController通过self.view addSubView方法出现时,我在我的视图控制器中实现了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;
}