I have resolve this. I have make two changes. 1. Edit loadPhotoGallery method 2. Create new method for fetching photos and displayed into grid.
My code for loadPhotoGallery is following.
- (void) loadPhotoGallery{
NSLog(@"fetchAllPhotos");
GDataServiceGooglePhotos *service = [self photoService];
GDataServiceTicket *ticket;
NSURL *feedURL = [GDataServiceGooglePhotos photoFeedURLForUserID:@"xyz@gmail.com" albumID:@"12345" albumName:nil photoID:nil kind:nil access:nil];
ticket = [service fetchFeedWithURL:feedURL delegate:self didFinishSelector:@selector(photosListTicket:finishedWithFeed:error:)];
feedURL = nil;
}
And code for displaying Photos into Grid is following.
-(void)displayGrid{
int x =0 ,y =0, counter =1;
for (int i=0; i<[self.photos count]; i++) {
GDataEntryPhoto *photoAlbum = [self.photos objectAtIndex:i];
GDataTextConstruct *textConstruct = [photoAlbum title];
NSString *stringTitle = [textConstruct stringValue];
NSLog(@"%@",stringTitle);
GDataMediaGroup *mediaGroup = [photoAlbum mediaGroup];
NSArray *arrMediaThumbs = [mediaGroup mediaThumbnails];
GDataMediaThumbnail *mediaThumbnail =[arrMediaThumbs objectAtIndex:2];
NSLog(@"%@", [mediaThumbnail URLString]);
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[mediaThumbnail URLString]]];
UIImage *img = [UIImage imageWithData:data];
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
imgView.frame = CGRectMake(x, y, 106, 106);
[scrPhoto addSubview:imgView];
UIButton *btn= [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = imgView.frame;
btn.tag = counter;
[btn addTarget:self action:@selector(btnPhotoClicked:) forControlEvents:UIControlEventTouchUpInside];
[scrPhoto addSubview:btn];
if(counter %3 == 0 ){
y = y +106;
x = 0;
} else{
x =x + 106;
}
counter++;
}
[scrPhoto setContentSize:CGSizeMake(320, y)];
}