마다 의 행 수가 서로 다른 UITableView가 있습니다.섹션 당 UITableView의 잘못된 셀 값
- (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;
}
내가 그는 수학 문제입니다 확신 해요 : 나는 올바른 결과를 달성하려고하는 그 코드를했다.
도움 주셔서 감사합니다.
편집 됨 : 그 엄청난 수의 267575552가 온거야 어디에서
'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 267575552 beyond bounds [0 .. 101]'
:
NSMutableArray *arrayofChannelsOffsets=[[NSMutableArray alloc]initWithCapacity:[arrayofChannelsCount count]];
NSNumber* zero = [NSNumber numberWithInteger:0];
[arrayofChannelsOffsets addObject:zero];
for (int j=1; j<[arrayofChannelsCount count]; j++) {
NSUInteger sum=(int)[arrayofChannelsOffsets objectAtIndex:j-1]+(int)[arrayofChannelsCount objectAtIndex:j-1];
NSNumber* num = [NSNumber numberWithInteger:sum];
[arrayofChannelsOffsets addObject:num];
NSLog(@"%lu count offset:",(unsigned long)[arrayofChannelsOffsets count]);
}
for (int i= 0 ; i < indexPath.section ; i++) {
pos =[[arrayofChannelsOffsets objectAtIndex:i] intValue] + indexPath.row;
}
cell.channelName.text=[arrayofChannelName objectAtIndex:pos];
나는 이상한 오류가 있습니다.
행 '값. 문제는 90 % 해결되었습니다. arrayofChannelName의 첫 번째 요소 (1)로 시작하는 이유와 0 요소가 아닌 이유를 알지 못합니다 (나중에 사용자가 알아챈 것처럼 코드를 최적화하려고합니다). – androniennn
@androniennn 실수로 생각한 것 같습니다. 루프의'<= '를 루프의'<'로 바꾸면 문제가 해결됩니다. – dasblinkenlight
큰 존경의 남자! 당신은 언제나처럼 최고입니다. :) 그리고 이제는 내가 말한 것처럼 코드를 최적화 할 것입니다. 매우 대단히 감사합니다, 당신은 내 하루를 확인합니다 :). – androniennn