2014-10-01 2 views
1

연습을 위해 나는 에있는 가치를 표시하거나 숨기고있다. UITableViewMXPlayer와 같이 android를 좋아한다. 값을 추가하면 NEW을 lable에 표시해야합니다. 맞춤 셀을 만들었습니다. 일단 값을 읽으면 다음보기에 표시되고 목록보기로 되돌아 와서 예외가 표시됩니다. 그러나 다른 값을 클릭하면 이전 값이 변경됩니다. 그래서iOS7의 UITableView에서 새로운 값 표시/숨기기?

답변

1

단순한 실수가 다시는 같은 이름을 부여 ..이 나를 only..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]; 
} 

far..help 있도록

이 코드 나는 시도는 잘못된 것이므로 NEW에서 VIEW로 변경해야합니다.

- (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]; 
}