Cocorico
Cocorico

Reputation: 2347

Can't seem to hide my UIImageView

I created a subclass of UIImageView that I need to re-use all over my app. It is a progress bar that looks like a football. 2 of its methods are:

-(void)showFootball {
    self.hidden = NO;
    // other code
}

-(void)hideFootball {
    self.hidden = YES;
}

and when the subclass initWithCoder I include this:

self.image = [UIImage imageNamed:@"cristiano.png"];
self.hidden = YES;

When I include this subclass into my project, and put it on the storyboard, I have a spot where I say

[self.soccerBallTimer show];

and of course it appears on the screen. But when I say

[self.soccerBallTimer hide];

it does not disappear. I have also tried thing inside the subclass like

self.image = nil;

and that also no helps. Any ideas?

edit: My init is like this:

-(id) initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    self.image = [UIImage imageNamed:@"cristiano.png"];
    self.hidden = YES;
    NSLog(@"init with coder");
    return self;
}

Upvotes: 0

Views: 88

Answers (1)

Doro
Doro

Reputation: 2413

Maybe you should remove it from superview (you can do this with animation) and re-add when you call 'show'

Upvotes: 1

Related Questions