tags:

views:

88

answers:

0

Hi,

In my app I created and tiled programmatically lots of UIImageView and set its tag from 1 - N,

int i;
int x=0,y=0;
for(i=0;i<MAX_VALUE;i++)
{
   UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:IMAGE_NAME]];
   img.tag = i+1;
   img.frame = CGRectMake(x,y,IMAGE_W,IMAGE_H);
   [self.view addSubview:img];

   if((i+1) % WIDTH == 0)
   {
      x=0;
      y+=IMAGE_H;
   }
   else
      x+=IMAGE_W;
}

I set a tag in each UIImageView so that I can access its array index and another purposes. Then I added a UIView at the bottom of my screen.

My problem is sometimes when I access the UIImageView with tag number 1 the UIView that I added is the one I access and not the actual UIImageView with tag number 1 even though I didn't specify a tag number in my added UIView. What do you think causing this problem?

Thanks.