Reputation: 37
I create an UIImageView then I assing a blurredbackgroundimage to it in ApplicationDidLaunch. This imageview overlaps the whole screen and is destined to cover the underlying view controller
UIImage *captureImage = [self captureView:tabBar.view];
backgroundImage.image = [captureImage applyExtraLightEffect];
backgroundImage.frame = [[UIScreen mainScreen] applicationFrame];
[tabBar.view addSubview:backgroundImage];
Then I ask for touch ID which shows up nicely. If TouchID authentication is successful I want to remove the background image with a nice fadeout animation
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"Are you the device owner?"
reply:^(BOOL success, NSError *error) {
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"There was a problem verifying your identity."
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
exit(0);
return;
}
if (success) {
NSLog(@"Passcode via TOUCH ID entered OK");
[UIView animateWithDuration:0.5
animations:^{backgroundImage.alpha = 0;}
completion:^(BOOL finished){[[tabBar.view viewWithTag:13] removeFromSuperview];; }];
// [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
[UIView setAnimationDelegate:self];
}
Now my problem is that the code gets executed right away, but the removal of the backgroundImage frame takes like 5-10 seconds to execute. It happens on all my iDevices. I do not understand why there is a delay before the removal of the superview. Does anyone have any clue?
Upvotes: 0
Views: 110
Reputation: 1139
The completion block probably isn't returning on the main thread. If that's the case, then views will behave in unexpected ways if you try to change them. Try putting all of your view manipulation code inside a dispatch_async(dispatch_get_main_queue())
block.
Upvotes: 2