View Full Version : Touch not detected on subview

Apr 27, 2009, 07:44 PM
touchesBegan is not getting called when I expect it to.

In my viewcontroller I have:

- (void)loadView {
statsView = [[StatsView alloc] initWithFrame:CGRectMake(14, 55, 292, 371)];

self.view = statsView;
[statsView release];

Then in statsView I load an image:

NSString *bgImageString = [[NSBundle mainBundle] pathForResource:@"prefs_colored_bg" ofType:@"png"];
UIImage* bgImage = [[UIImage alloc] initWithContentsOfFile:bgImageString];
UIImageView *bgImageView = [[UIImageView alloc] initWithImage: bgImage];
[bgImage release];
frame.origin.x = 0;
frame.origin.y = 0;
bgImageView.frame = frame;
[self addSubview:bgImageView];
[bgImageView release];

When I touch the image, touchesBegan is not getting called. Why would that be?

Jan 23, 2010, 05:28 PM
is userInteractionEnabled on in your imageview?