I have this code for each index of my uitableview
if (indexPath.row == 6){
UIImageView *blog = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blog.png"]];
[cell setBackgroundView:blog];
UIImageView *selectedblog = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blogSel.png"]];
cell.selectedBackgroundView=selectedblog;
cell.backgroundColor = [UIColor clearColor];
[[cell textLabel] setTextColor:[UIColor whiteColor]];
return cell;}
and I have two sections, with 5 rows in each section. How can I put indexPath.row 1 thru 5 in section 1 and indexPath.row 6 thru 10 in section 2?
Now your table view will expect 2 sections with 5 rows each, and try to draw them. Then, in
cellForRowAtIndexPath:The above logic with
actualIndexleads to:If you have an underlying array (or other flat container class) of items backing your table cells, this will allow you to fill out multiple sections in the table view using those items.