-1

I am working in a iPad application. I'm using a UITableView to create a table and insert 2 UIImageViews in each cell. I tried to set image in both UIImageViews, but index path values start from 0,1,2,3,4 etc...

Each UIImageView has same image in first cell. How to fix this issue?

enter image description here

Example:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // ImageArray have 5images;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{


    return [ImageArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    imgView1.image = [imageArray objectAtIndex:indexPath.row]; 
    imgView2.image = [imageArray objectAtIndex:indexPath.row]; 
 }
SampathKumar
  • 2,525
  • 8
  • 47
  • 82

1 Answers1

0

After formatting your code it becomes clear that you are assigning the same image from the array to each of the two image views. You will need an imageViewArray that has the double amount of members.

Also, you should not check for the count of your image array but for the row of your index path.

Mundi
  • 79,884
  • 17
  • 117
  • 140