drawRect not being called in my subclass of UIImageView
Posted
by Ben Collins
on Stack Overflow
See other posts from Stack Overflow
or by Ben Collins
Published on 2010-04-10T03:40:28Z
Indexed on
2010/04/10
3:43 UTC
Read the original article
Hit count: 717
I have subclassed UIImageView and tried to override drawRect so I could draw on top of the image using Quartz 2D. I know this is a dumb newbie question, but I'm not seeing what I did wrong. Here's the interface:
#import <UIKit/UIKit.h>
@interface UIImageViewCustom : UIImageView {
}
- (void)drawRect:(CGRect)rect;
And the implementation:
#import "UIImageViewCustom.h"
@implementation UIImageViewCustom
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
}
return self;
}
- (void)drawRect:(CGRect)rect {
// do stuff
}
I set a breakpoint on drawRect
and it never hits, leading me to think it never gets called at all. Isn't it supposed to be called when the view first loads? Have I incorrectly overridden it?
© Stack Overflow or respective owner