-(void)viewDidLoad{
//////// JP -13-2-2012
/////For Custome ImagePicker Control From http://www.raywenderlich.com/130/how-to-write-a-custom-image-picker-like-uiimagepicker
UIScrollView *view = [[UIScrollView alloc]
initWithFrame:[[UIScreen mainScreen] bounds]];
int row = 0;
int column = 0;
for(int i = 0; i < _thumbs.count; ++i) {
UIImage *thumb = [_thumbs objectAtIndex:i];
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(column*100+24, row*80+10, 64, 64);
[button setImage:thumb forState:UIControlStateNormal];
[button addTarget:self
action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];
button.tag = i;
[view addSubview:button];
if (column == 2) {
column = 0;
row++;
} else {
column++;
}
}
[view setContentSize:CGSizeMake(320, (row+1) * 80 + 10)];
self.view = view;
[view release];
[super viewDidLoad];
}
- (IBAction)buttonClicked:(id)sender {
UIButton *button = (UIButton *)sender;
UIImage *selectedImage = [_images objectAtIndex:button.tag];
// Do something with image!
}
----Here thumb and images are array..
No comments:
Post a Comment