I'm stuck on the following code. Some how my UIButton Extended class cant show or hide an UIImageView
My methods are being called and the imageview is not nil.
Here is the code:
@interface UILinkedImageButton : UIButton {
IBOutlet UIImageView *linkImageView;
}
@property (nonatomic, retain) IBOutlet UIImageView *linkImageView;
@end
#import "UILinkedImageButton.h"
@interface UILinkedImageButton ()
- (void)showImage;
- (void)hideImage;
@end
-------------------------------------------------------------------------------------------------
@implementation UILinkedImageButton
@synthesize linkImageView;
- (void) dealloc{
[linkImageView release], linkImageView = nil;
[super dealloc];
}
- (id) initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self){
[self addTarget:self action:@selector(showImage) forControlEvents:UIControlEventTouchDown];
[self addTarget:self action:@selector(hideImage) forControlEvents:UIControlEventTouchUpInside];
[self addTarget:self action:@selector(hideImage) forControlEvents:UIControlEventTouchUpOutside];
}
return self;
}
- (void)showImage
{
if(self.imageView){
NSLog(@"UILinkImageButton - showImage - currentStatus: %@", self.imageView);
self.imageView.hidden = NO;
[self.superview layoutIfNeeded];
}
}
- (void)hideImage
{
if(self.imageView){
NSLog(@"UILinkImageButton - hideImage");
self.imageView.hidden = YES;
}
}
@end