-(void)goToGridView { int k1,j1; int i = 0, j = 0,k = 0; int x = 7; int y = 0,count = 0; int totalSubViews = [[self.scrlImages subviews] count]; // NSLog(@"totalSubViews:=%d",totalSubViews); if (totalSubViews != 0) { for (k1=0,j1=0; k1 < totalSubViews; k1++ ) { if ([[[self.scrlImages subviews] objectAtIndex:j1] isKindOfClass:[UIActivityIndicatorView class]]) { UIActivityIndicatorView *thisLabel = [[self.scrlImages subviews] objectAtIndex:j1]; [thisLabel removeFromSuperview]; thisLabel = nil; [thisLabel release]; } else if ([[[self.scrlImages subviews] objectAtIndex:j1] isKindOfClass:[UIImageView class]]) { UIImageView *imgView = [[self.scrlImages subviews] objectAtIndex:j1]; [imgView removeFromSuperview]; imgView = nil; [imgView release]; } else if ([[[self.scrlImages subviews] objectAtIndex:j1] isKindOfClass:[EGOImageButton class]]) { EGOImageButton *lbl = [[self.scrlImages subviews] objectAtIndex:j1]; [lbl removeFromSuperview]; lbl = nil; [lbl release]; } else if ([[[self.scrlImages subviews] objectAtIndex:j1] isKindOfClass:[UILabel class]]) { UILabel *lbl = [[self.scrlImages subviews] objectAtIndex:j1]; [lbl removeFromSuperview]; lbl = nil; [lbl release]; } else if([[[self.scrlImages subviews] objectAtIndex:j1] isKindOfClass:[UIButton class]]) { UIButton *thisButton = [[self.scrlImages subviews] objectAtIndex:j1]; [thisButton removeFromSuperview]; } else j1++; } } NSMutableArray *sectionItems; count = [arrPlaces count]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; for (i = 1; i<= count ; i++) //[arr count] { sectionItems = [sections objectAtIndex:i-1]; int tag = 1; if (i > count ) break; UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(x + 58, y + 3,200,38)] ; headerLabel.tag = [[NSString stringWithFormat:@"7%d",i] intValue]; headerLabel.backgroundColor = [UIColor clearColor]; headerLabel.text = [NSString stringWithFormat:@"%@",[arrPlaces objectAtIndex:i-1]]; headerLabel.textAlignment = UITextAlignmentCenter; headerLabel.font = [UIFont fontWithName:@"CALIBRI" size:17.5]; headerLabel.font = [UIFont boldSystemFontOfSize:17.5]; headerLabel.textColor = [UIColor whiteColor]; UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(CountryLabel:)]; [headerLabel setUserInteractionEnabled:YES]; [headerLabel addGestureRecognizer:tap]; [tap release]; // if not using ARC [self.scrlImages addSubview:headerLabel]; y += 42; for (j = 0; j< [sectionItems count]; j++) { if (tag/2 >= [sectionItems count]) break; for (k = 0 ; k< 3; k++) { if (tag/2 >= [sectionItems count]) break; Item *item; if (tag >= 2) { item = [sectionItems objectAtIndex:tag/2 ]; } else { item = [sectionItems objectAtIndex:tag - 1]; } NSURL *imgURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",item.image_url]]; UIImageView *imgBorder = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"border"]] autorelease]; imgBorder.frame = CGRectMake(x = x, y = y, 97.3, 114.5); [self.scrlImages addSubview:imgBorder]; EGOImageButton *btnImage = [[[EGOImageButton alloc] initWithPlaceholderImage:[UIImage imageNamed:@""]] autorelease]; [btnImage addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; NSString *strTag = [NSString stringWithFormat:@"%d%d",i,tag]; [btnImage setTag:[strTag intValue]]; btnImage.frame = CGRectMake(x + 2.5, y + 3 , 92, 92); [btnImage performSelector:@selector(setImageURL:) withObject:imgURL afterDelay:2.0]; // [btnImage performSelectorOnMainThread:@selector(setImageURL:) withObject:imgURL waitUntilDone:NO]; // [btnImage performSelectorInBackground:@selector(setImageURL:) withObject:imgURL]; // [btnImage setImageURL:imgURL]; [self.scrlImages addSubview:btnImage]; UILabel *lblCategory = [[UILabel alloc] initWithFrame:CGRectMake(x, y + 99.5, 97.3, 11)]; lblCategory.textAlignment = UITextAlignmentCenter; lblCategory.textColor = [UIColor blackColor]; lblCategory.backgroundColor = [UIColor clearColor]; lblCategory.font = [UIFont fontWithName:@"CENTURY" size:10]; lblCategory.text = [NSString stringWithFormat:@"%@",item.image_category]; [self.scrlImages addSubview:lblCategory]; tag++; tag++; x = x + 104.3; [lblCategory release]; } x = 7; y = y + 122.5; }y = y - 9; [headerLabel release]; } [HUD hide:YES]; [pool release]; if (y <= 331) { self.scrlImages.contentSize = CGSizeMake(320, y + 220); } else { self.scrlImages.contentSize = CGSizeMake(320, y + 15); } }