2014-10-01 60 views
1

在练习中我正在做的显示/隐藏值在UITableViewMXPlayer在android中。 当我添加的值,它应该显示在标签我已经为自定义单元格。一旦我读取值,它将显示在下一个视图,然后回到列表视图显示正确,因为我例外,但如果我点击另一个值,它会改变以前的值。在iOS7中显示/隐藏UITableView中的新值?

这个代码,我试了far..help我

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    static NSString *Identifier = @"ceelll"; 
    customCell *cell =(customCell *) [tableView dequeueReusableCellWithIdentifier:Identifier]; 
    if (cell==nil) { 
     cell=[[[NSBundle mainBundle]loadNibNamed:@"customCell" owner:self options:nil]objectAtIndex:0]; 
    } 

    cell.dataLbl.text=self.listData[indexPath.row]; 
     if([self.checkedData isEqual:indexPath]) 
    { 
     [email protected]"VIEW"; 
     cell.NewHideLbl.textColor=[UIColor greenColor]; 

    } 
    else 
    { 

      [email protected]"NEW"; 
      cell.NewHideLbl.textColor=[UIColor redColor]; 

    } 
    return cell; 
} 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    if(self.checkedData) 
    { 
     customCell* cell =(customCell*) [tableView cellForRowAtIndexPath:self.checkedData]; 
     [email protected]"NEW"; 
     cell.NewHideLbl.textColor=[UIColor redColor]; 

    } 
    if([self.checkedData isEqual:indexPath]) 
    { 
     self.checkedData = nil; 
    } 
    else 
    { 
     customCell* cell =(customCell*) [tableView 
                   cellForRowAtIndexPath:indexPath]; 
     [email protected]"VIEW"; 
     cell.NewHideLbl.textColor=[UIColor greenColor]; 


     self.checkedData = indexPath; 
    } 
    self.detailObj.tempStr=self.listData[indexPath.row]; 
    [self.navigationController pushViewController:self.detailObj animated:YES]; 
} 

这是学习的目的only..Help我在此先感谢..

回答

1

简单的错误再次给你相同的名称,以便其因此您需要更改NEW以查看

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    if(self.checkedData) 
    { 
     customCell* cell =(customCell*) [tableView                cellForRowAtIndexPath:self.checkedData]; 
     // [email protected]"NEW"; here again you are assigning label NEW so its getting new one 
     [email protected]"VIEW"; 
     cell.NewHideLbl.textColor=[UIColor greenColor]; 

    } 
    if([self.checkedData isEqual:indexPath]) 
    { 
     self.checkedData = nil; 
    } 
    else 
    { 
     customCell* cell =(customCell*) [tableView 
                   cellForRowAtIndexPath:indexPath]; 
     [email protected]"VIEW"; 
     cell.NewHideLbl.textColor=[UIColor greenColor]; 


     self.checkedData = indexPath; 
    } 
    self.detailObj.tempStr=self.listData[indexPath.row]; 
    [self.navigationController pushViewController:self.detailObj animated:YES]; 
}