Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

99miles

macrumors member
Original poster
Oct 10, 2008
50
0
I have a UIView and in initWithFrame I create an image and a label, adding the label to the image view:


Code:
label		= [[UILabel alloc] init];
label.frame = CGRectMake(20, 20, 80, 80);
[label setTextAlignment:UITextAlignmentCenter];
[label setBackgroundColor:[UIColor colorWithRed:0 green:1 blue:0 alpha:0]];


// load background image
imageObj		= [facade imageObj1];
imageView		= [[UIImageView alloc] initWithImage: imageObj];
imageView.frame	= CGRectMake(20, 20, 80, 80);
		
[imageView addSubview:label];
[self addSubview:imageView];

I then use the label as a 'hotspot' in a hittest to decide whether or not the view has been touched.

I then create a bunch of instances of this and place them on various parts on the screen. The labels all appear positioned correctly, but the problem is that for the instances at the upper portion of the touch screen my finger has to be higher on the view for the hittest to return true, than for those further down the screen.

I just tried calling setNeedsDisplay after set the views frame, but it didn't help. Any other ideas? Is there something else I need to do to make sure the contents of the view have their positioning updated correctly? As I said, they appear in the correct location, so I'm thinking it's something a little beyond that.

I'd appreciate any thoughts.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.