use*_*503 5 objective-c storyboard tableview
我正在尝试删除或隐藏tableview内部的静态单元格.我试图隐藏它的功能viewDidLoad.这是代码:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView beginUpdates];
[self.tableView deleteSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:YES];
[self.tableView endUpdates];
[self.tableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)
部分仍然出现.我正在使用故事板.能帮帮我吗?谢谢!
我发现通过覆盖numberOfRowsInSection来隐藏部分是最方便的.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ( section == 1 )
// Hide this section
return 0;
else
return [super tableView:self.tableView numberOfRowsInSection:section];
}
Run Code Online (Sandbox Code Playgroud)
Nik*_*Nik -2
似乎reloadData使表视图重新读取数据源。您还应该在调用之前从 dataSource 中删除数据reloadData。removeObject:如果您使用数组,请在调用之前删除所需的对象reloadData。
| 归档时间: |
|
| 查看次数: |
4087 次 |
| 最近记录: |