0

I have made a game of Tic-Tac-Toe. If the game ends in a tie, an animated hudView appears for a couple of seconds. Then the game starts over, and that's when my problems occur. It doesn't respond to me tapping on screen to draw 'X' or 'O''s anymore. My suspicion is that the hudView is still there. I have tried different things to remove it, with no luck.

+ (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;
}

And the animation:

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

In the completion block, I have tried the following:

    [self.superview removeFromSuperview];

In my ViewController where all of this gets called I've tried:

HudView *hudView = [HudView hudInView:self.view animated:YES];
hudView.text = @"\tIt's a Tie\n";




[hudView removeFromSuperview];
[self.view removeFromSuperview]
[hudView.superview removeFromSuperview];

Nothing I've tried so far is working. Any help would be much appreciated.

Nilzone-
  • 2,766
  • 6
  • 35
  • 71
  • @ali59a please explain why dispatch_async would help me solve this? – Nilzone- Mar 19 '14 at 16:00
  • Can you please try the solution below ? – Ali Abbas Mar 19 '14 at 16:03
  • 1
    Where do you set `view.userInteractionEnabled` back to YES? It looks like the hud initializer method disables interaction, but your completion block never reenables it. – Aaron Mar 19 '14 at 16:15
  • 1
    @Aaron that was exactly my problem ;) I just figured it out. That and the [hudView removeFromSuperview]; made everything work as it should – Nilzone- Mar 19 '14 at 16:19

0 Answers0