I want to display images in a TableView. I can display one image in one cell, but I want to display four images instead of one image in every row like a photo library and when I select any image, it will open as a slide show as it happened in the photo library.
My images are stored in Document Directory. How can I do this?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tablView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//Adjust your imageview frame according to you
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0, 0.0, 470.0, 80.0)];
[imageView setImage:[arrayOfImages objectAtIndex:indexPath.row]];
[cell.contentView addSubview:imageView];
return cell;
}
Now I’m just explaining how to show an image like iPhone library. Use UIScrollView instead of UITableView. I think this will be better!
After getting all images in an array, try this code:
And you can handle each image like this
(Note: First of all, this is up to you and your logics so please make your logic strong. Nobody can write everything here. If you are a beginner then please do study for sometime “All The Very Best”)