这是我的自定义单元代码
-(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];
}
我是iOS新手,请帮助我。