CGRect frame;
MyButton *btn = [[MyButton buttonWithType:UIButtonTypeCustom] retain];
btn.index = i;
btn.value = [NSString stringWithFormat:@"name%d",i];
NSString *named = [array objectAtIndex:i];
NSURL *url2 = [NSURL URLWithString:named];
UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:url2]];
[btn setImage:img forState:UIControlStateNormal];
frame.size.width = 120;
frame.size.height = 200;
frame.origin.x = (i%4)*120+20;
frame.origin.y = i/4*120+20;
break;
[btn setFrame:frame];
[btn setBackgroundColor:[UIColor clearColor]];
[btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
[btn release];