2011-03-30 3 views

답변

3

클리어 (예를 [dataSourceMutableArray removeAllObjects]에 대한) 데이터 소스를 다시로드 테이블 ([tableView reloadData])

+1

실제로 모든 코드를 다음에 사용하고 있습니다 ----- if (cell == nil) \t { } 그래서 다시로드 할 때 행에 데이터가 표시되지 않습니다. –

+0

디자인을 다시 고려하십시오. 어쨌든, tableView : numberOfRowsInSection :이 0을 리턴하고 reloadData를 호출하도록하여 모든 행을 "제거"할 수 있습니다. – ssteinberg

1

나는 tableView의 dataSource에서 모든 값을 제거 할 수 있다고 생각합니까? 그런 다음있는 tableView

+0

사실 내 세포가 수정되었습니다 에드윈버그에게 주어진 코멘트를 봐주세요. 그래서 새로운 값으로 테이블을 새로 고침하면 대체되지 않습니다. –

1
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 

    return 0; 

} 


// Customize the number of rows in the table view. 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

    return 0; 

} 

를 다시로드하거나 cellForRowAtIndextPath 기능

return nil; 대신 return cell;을 지정하거나 모든 값을 제거 할 수 있습니다 배열 cellForRowAtIndexPath이 같은

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

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    // Configure the cell. 

    // remove below line 
    //cell.textlabel.text=[array objectAtIndex:indextPath]; 

    return cell; 
} 
+0

_please_ 미리보기 사용 방법에 대해 알아보십시오. – hop

+0

고맙습니다. 감사합니다. :) –

관련 문제