You are on page 1of 2

favorite -(IBAction)populateScroll { CGFloat leftMark = 10; CGFloat topMark = 10; for (int i = 0; i < [appDelegate.

airFavList count]; i++) { if (i % 3 == 0 && i > 0) { leftMark = 10; topMark += 90; } UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(leftMark, topMark, 80, 80)]; [imgView setContentMode:UIViewContentModeScaleAspectFit]; imgView.image = [[appDelegate.airFavList objectAtIndex:i] imageFav]; [scroll addSubview:imgView]; [imgView release]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.tag = [[[appDelegate.airFavList objectAtIndex:i] idDatabase] intValue]; // btn.tag = i; btn.frame = CGRectMake(leftMark, topMark, 100, 100); [btn addTarget:self action:@selector(pushPhoto:) forControlEvents:UIControlEventTouchDown]; [scroll addSubview:btn]; leftMark += 90; } topMark += 100; [scroll setContentSize:CGSizeMake(scroll.frame.size.width, topMark)]; [activity setHidden:YES]; [activity stopAnimating]; } -(void) pushPhoto:(id)sender { UIButton *btn = (UIButton *)sender; if (m == nil) { m = [[DBObject alloc] init]; } NSLog(@"%d",btn.tag);

// m = (DBObject*)[appDelegate.airFavList objectAtIndex:btn.tag]; m = [Sqlite getAirplaneById:[appDelegate getDBPath] iddb:[NSString stringWithFormat:@"%d",btn.tag]]; mainImage.image = [Sqlite getImageWithMd5:m.hash_img0link db: [appDelegate getDBPath]]; }

You might also like