gpt4 book ai didi

ios - ApplicationDidLaunch 中的 RemoveFromSuperView UIImageView 延迟执行

转载 作者:行者123 更新时间:2023-11-28 21:53:42 24 4
gpt4 key购买 nike

我创建了一个 UIImageView,然后在 ApplicationDidLaunch 中为它分配了一个模糊的背景图像。这个 imageview 覆盖了整个屏幕,注定要覆盖底层的 View Controller

UIImage *captureImage = [self captureView:tabBar.view];
backgroundImage.image = [captureImage applyExtraLightEffect];
backgroundImage.frame = [[UIScreen mainScreen] applicationFrame];

[tabBar.view addSubview:backgroundImage];

然后我要求显示很好的触摸 ID。如果 TouchID 身份验证成功,我想用漂亮的淡出动画删除背景图像

[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];
}

现在我的问题是代码会立即执行,但是删除 backgroundImage 框架需要 5-10 秒才能执行。它发生在我所有的 iDevices 上。我不明白为什么在删除 super View 之前会有延迟。有人知道吗?

最佳答案

完成 block 可能没有在主线程上返回。如果是这种情况,那么如果您尝试更改它们, View 将以意想不到的方式运行。尝试将所有 View 操作代码放入 dispatch_async(dispatch_get_main_queue()) block 中。

关于ios - ApplicationDidLaunch 中的 RemoveFromSuperView UIImageView 延迟执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27339204/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com