I created a subclass of UITableViewCell and added two identical UIViews that have exactly the same format.
MyTableViewCell:
UIView *leftView = [[UIView alloc ] initWithFrame:CGRectMake(0, 0, 160, 100)];
UIView *rightView = [[UIView alloc ] initWithFrame:CGRectMake(160, 0, 160, 100)];
[self.contentView addSubview:leftView];
[self.contentView addSubview:rightView];
Each time I need to assign two values when indexPath.row indicates only one index. This is my current code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row %2) {
cell.label1.text = [array objectAtindex:indexPath.row] objectForKey:@"name"];
cell.label2.text =[array objectAtindex:indexPath.row] objectForKey:@"name"];
}
}
Cell layout:
|------------|--------------|
| 1 | 2 |
-----------------------------
| 3 | 4 |
-----------------------------
| 5 | 6 |
-----------------------------
The result is that cells 2,3,6 are empty and cells 1,4,5 filled. I have no idea how to populate data into the two same UIViews.
Assuming your
arraycontains exactly twice as many items as the table has rows, it should work like this: