2014-02-14 1 views
0

uitableview 셀은 셀을 재사용하지만 셀을 재사용하고 싶지 않습니다. tableView에서 셀의 텍스트가 삭제됩니다. 그래서 didloadview에 모든 셀을 만들고 싶습니다. 이 코드를 작성하는 방법 ?? !!dequeueReusableCell을 비활성화하여 모든 tableviewCell보기를로드하는 방법은 무엇입니까?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
//test 
setting_detail_cell *customCell = (setting_detail_cell*)[tableView cellForRowAtIndexPath:indexPath];*** 

NSString *keyword1 = [[customCell Key1] text]; 
// 
setting_cell=[tableView dequeueReusableCellWithIdentifier:CellTableIdentifier]; 

rowData = self.PPT_Setting[indexPath.row]; 
[setting_cell setNumber:rowData[@"page_num"]]; 
    @try { 
     rowData_keyword =self.Keyword_list[indexPath.row]; 
     setting_cell.Key1.text = rowData_keyword[@"key1"]; 
     setting_cell.Key2.text = rowData_keyword[@"key2"]; 
     setting_cell.Key3.text = rowData_keyword[@"key3"]; 
     NSLog(@"index1 : %d",indexPath.row);; 
     NSLog(@"cell : %@",setting_cell); 

     if ([rowData_keyword[@"key1"] isEqualToString:@"(null)"] == YES) { 
      setting_cell.Key1.text = @" "; 
     } 
     if ([rowData_keyword[@"key2"] isEqualToString:@"(null)"] == YES) { 
      setting_cell.Key2.text = @" "; 
     } 
     if ([rowData_keyword[@"key3"] isEqualToString:@"(null)"] == YES) { 
      setting_cell.Key3.text = @" "; 
     } 
    }@catch (NSException *exception) { 
     NSLog(@"%@",exception); 
    } 

return setting_cell; 
} 
+0

'dequeueReusableCellWithIdentifier' 코드를 제거하고 항상 init 셀을 할당하십시오. –

+0

그게 무슨 뜻이야?! 세포를 재사용 할 때 원하는 모든 것을 할 수 있습니다. – Injectios

+1

dequeue-method를 사용하지 말고 대신 수동으로 셀을 초기화하십시오. 그러나 나는 정말로 당신이 그것을하고 싶지 않다는 것을 확신합니다! 당신이 이것을 원한다는 이유를 설명 할 수 있다면, 우리는 아마도 당신이 실제로 가지고있는 문제에 대한 해결책을 줄 수 있습니다. – Moonwalkr

답변

0

셀 찾기 재사용. 코드 셀이 재사용되지 않기 때문입니다. 당신이 표시하는 세포의 많은 너무 많은 메모리 셀을 설정할 때 사용하고있는 경우,이 메모리 오버 헤드가 발생합니다

UITableViewCellAccessoryCheckmark 유형

0

고유 식별 사용

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath (NSIndexPath*)indexPath 
{ 
    static NSString *cellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; 

    if (!cell) 
     cell = [[UITableViewCell alloc] initWithStyle:yourStyle reuseIdentifier: cellIdentifier]; 

    return cell; 
} 

. 재사용이 가능한 세포를 사용하여 사과를 피하십시오.

정적으로 할당 된 셀을 원한다면 셀을 만들어 배열에 유지 한 다음 해당 인덱스에서 셀을 반환하십시오 (이 방법은 권장되지 않음).