我做了一个井字游戏。如果游戏以平局结束,动画 hudView 会出现几秒钟。然后游戏重新开始,这就是我出现问题的时候。它不再响应我点击屏幕绘制“X”或“O”。我的怀疑是 hudView 仍然存在。我尝试了不同的方法来删除它,但没有运气。
+ (instancetype)hudInView:(UIView *)view animated:(BOOL)animated
{
HudView *hudView = [[HudView alloc] initWithFrame:view.bounds];
hudView.opaque = NO;
[view addSubview:hudView];
view.userInteractionEnabled = NO;
[hudView showAnimated:YES];
return hudView;
}
和动画:
- (void)showAnimated:(BOOL)animated
{
if (animated) {
self.alpha = 0.0f;
self.transform = CGAffineTransformMakeScale(1.3f, 1.3f);
[UIView animateWithDuration:4.5 animations:^{
self.alpha = 1.0f;
self.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished) {
self.alpha = 0.0f;
}];
}
}
在完成块中,我尝试了以下操作:
[self.superview removeFromSuperview];
在我的所有这些都被调用的 ViewController 中,我尝试过:
HudView *hudView = [HudView hudInView:self.view animated:YES];
hudView.text = @"\tIt's a Tie\n";
[hudView removeFromSuperview];
[self.view removeFromSuperview]
[hudView.superview removeFromSuperview];
到目前为止,我没有尝试过任何工作。任何帮助将非常感激。