-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"Cell";
MagazineListCell* cell=(MagazineListCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell==nil)
{
NSArray *arr=[[NSBundle mainBundle]loadNibNamed:@"MagazineListCell" owner:nil options:nil];
cell=(MagazineListCell *)[arr objectAtIndex:0];
[cell setDelegate:self];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
NSMutableArray *arr=[[NSMutableArray alloc]init];
NSInteger startIndex;
NSInteger endIndex;
if(isLandscape)
{
startIndex=indexPath.row*3;
if (startIndex+3>[self.arrMagazine count ])
{
endIndex=[self.arrMagazine count];
}
else
{
endIndex=startIndex+3;
}
}
else
{
startIndex=indexPath.row*2;
if (startIndex+2>[self.arrMagazine count])
{
endIndex=[self.arrMagazine count];
}
else
{
endIndex=startIndex+2;
}
}
for (int x=startIndex; x<endIndex; x++)
{
[arr addObject:[self.arrMagazine objectAtIndex:x]];
}
[cell setSelectedIndex:btnSegment.selectedSegmentIndex];
[cell contentForTableViewCell:arr setUIMode:isLandscape] ;
arr=nil;
return cell;
}
答案 0 :(得分:0)
检查您的重用标识符是否已设置,因为您可能每次都在创建单元格。
主要问题可能是你每次创建的数组,循环填充然后传递给单元格。您应该在需要之前尝试完成所有设置。