如何停止在自定义单元格中重新加载数据?来自JSON的数据

时间:2016-01-11 07:18:22

标签: ios uitableview

这是我的自定义单元代码

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
ContestTableViewCell *cell = [myContestTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
    NSArray *myNib;
    myNib =[[NSBundle mainBundle]loadNibNamed:@"ContestTableViewCell" owner:self options:nil];
    cell =[myNib objectAtIndex:0];
}
if (selectedIndex==indexPath.row)
{
}
else
{
}
cell.fldExamTitleLbl.text = [fldExamTitleArray objectAtIndex:indexPath.row];
cell.fldExamStartDateLbl.text = [fldExamStartArray objectAtIndex:indexPath.row];
cell.prizeMoney.text =[prizeMoneyArray objectAtIndex:indexPath.row];
cell.firstReward.text = [firstRewardArray objectAtIndex:indexPath.row];
cell.secondReward.text = [secondRewardArray objectAtIndex:indexPath.row];
cell.thirdReward.text = [thirdRewardArray objectAtIndex:indexPath.row];

return cell;

}

didSelectRowAtIndexPath我正在写这段代码

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (selectedIndex == indexPath.row)
{
    selectedIndex = -1;
    [myContestTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    return;
}
if (selectedIndex != -1)
{
    NSIndexPath *prevPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
    selectedIndex = indexPath.row;
    [myContestTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:prevPath] withRowAnimation:UITableViewRowAnimationFade];
}
    selectedIndex = indexPath.row;
    [myContestTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

我正在获取这样的输出,它正在重新加载JSON的数据。 enter image description here

我是iOS新手,请帮助我。

0 个答案:

没有答案