Touch not detected on subview

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

  1. macrumors member

    Joined:
    Oct 10, 2008
    #1
    touchesBegan is not getting called when I expect it to.

    In my viewcontroller I have:
    Code:
    - (void)loadView {
    	statsView		= [[StatsView alloc] initWithFrame:CGRectMake(14, 55, 292, 371)];	
    
    	self.view = statsView;
    	[statsView release];
    }
    
    Then in statsView I load an image:

    Code:
    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. macrumors regular

    drf1229

    Joined:
    Jun 22, 2009
    #2
    is userInteractionEnabled on in your imageview?
     

Share This Page