как удалить все строки таблицы - PullRequest
0 голосов
/ 30 марта 2011

Может кто-нибудь сказать, что, как удалить все строки tableView

Ответы [ 3 ]

3 голосов
/ 30 марта 2011

Очистить источник данных (например, [dataSourceMutableArray removeAllObjects]) и перезагрузить таблицу ([tableView reloadData])

1 голос
/ 30 марта 2011
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 0;

}


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

    return 0;

}

или укажите return nil; вместо return cell; в cellForRowAtIndextPath функции

или вы можете удалить все значения в массиве в 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;
}
1 голос
/ 30 марта 2011

Я думаю, что вы можете удалить все значения в источнике данных tableView?Затем перезагрузите tableView

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...