Wrong cells values of UITableView per section
- by androniennn
I have a UITableView that has a different rows count in every section.
I made that code to try achieving a correct result:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier= @"channel";
ChannelsCell *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell) {
cell =[[ChannelsCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSInteger rowsCountSection = [[arrayofChannelsCount objectAtIndex:indexPath.section] intValue];// this variable has the number of rows of every section
NSUInteger pos = indexPath.section*count+ indexPath.row;
cell.channelName.text=[arrayofChannelName objectAtIndex:pos];
return cell;
}
I'm pretty sure that's a mathematic problem.
Thank you for helping.