Touch not detected on subview

Discussion in 'iOS Programming' started by 99miles, Apr 27, 2009.

  1. 99miles macrumors member

    Oct 10, 2008
    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?
  2. drf1229 macrumors regular


    Jun 22, 2009
    is userInteractionEnabled on in your imageview?

Share This Page