Wrong cells values of UITableView per section

Posted by androniennn on Stack Overflow See other posts from Stack Overflow or by androniennn
Published on 2013-06-25T14:04:25Z Indexed on 2013/06/25 16:21 UTC
Read the original article Hit count: 157

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.

© Stack Overflow or respective owner

Related posts about uitableview

Related posts about uitableviewcell