tnishanth
tnishanth

Reputation: 11

Display multiple images in Tableviewcell

How to display multiple images in a single cell on clicking forward and back button like shown in below image.

enter image description here

Upvotes: 0

Views: 1043

Answers (1)

W2S Solutions
W2S Solutions

Reputation: 141

I guess your table array will look like:

[
    {
        price   : "$ 000",
        adress  : "adress",
        size    : "size",
        imagesArray : [
                    {
                        imageName : "name",
                        image  : "image"
                    }
                  ]
    }
]

Use collection view in table view cell, and enable pagination for collection view. Pass images array to collection view

or

if use image view only in table view cell, you should maintain position of the images. So just create a mutable position array with table array count like table array as 3 values, and the position array should be like [0,0,0]. Initially, 0th index will be visible. so given values are 0.

in cellForIndex method:

NSArray * imageArray =[NSArray new];
imageArray = [[tableArray objectAtIndex:indexPath.row] valueForKey:@"imagesArray"]

NSInteger imageIndex = [positionArray objectAtIndex: indexPath.row];

cell.imageView.image = [imageArray objectAtindex:imageIndex] valueForKey:@"image"]

Set indexpath as a tag for arrow buttons.

if you click right arrow in 1st index of table view, In target method, get index from tag and increase value at 1st index value of position array. Now reload table view or particular cell.

Upvotes: 2

Related Questions