how to avoid delay when adding more than one button to scrollview in iPhone?
I need to add more than one button (its depend upon array count) to
UIScrollview.Now i am using the following code.This code is working
properly but more time ( delay for adding button) taking for this
function.Please help me..
for (int i=0; i< [imageArray count]; i++) {
NSURL *url = [NSURL URLWithString:[[imgArray
objectAtIndex:i]objectForKey:@"url"]];
UIImage *img = [UIImage imageWithData:[NSData
dataWithContentsOfURL:url]];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.frame = CGRectMake(xp, 0, 75, 75);
[button1 setImage:img forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];
button1.layer.borderColor = [UIColor whiteColor].CGColor;
button1.layer.borderWidth = 2.0;
[mScrollView addSubview:button1];
xp += button1.frame.size.width+15;
}
No comments:
Post a Comment