UIButton overlapping problem in the UIView?
- by sai
im trying to create buttons as ahierarchy, first some buttons are displayed if i click any of the buttons it will navigate to the next viewcontroller displaying some more buttons.
But here my problem is butons are overlapped with one another . means the buttons that should not be displayed are also comming along with those should be .
my code is
for(.................)
{
butt = [[UIButton alloc] initWithFrame:CGRectMake(...)];
image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[arr objectAtIndex:i]]]];
imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
[butt setBackgroundImage:imageView.image forState:UIControlStateNormal];
[butt setTag:i];
[butt addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
[containerView addSubview:butt];
[butt release];
x+=butt.frame.size.width+2*hgap;
i+=1;
if (i==count+1) //[arr count]
{
printf("\nIN BREAK BUTTON\n");
break;
}
}
y=y+(butt.frame.size.height+2*vgap);
}
Thankyou for the solution.