【发布时间】:2014-07-29 13:28:24
【问题描述】:
我正在开发一个应用程序。此应用程序包含 TableView 如果我在某些操作后单击要隐藏的行中的任何一行,任何人都可以帮忙吗?
【问题讨论】:
我正在开发一个应用程序。此应用程序包含 TableView 如果我在某些操作后单击要隐藏的行中的任何一行,任何人都可以帮忙吗?
【问题讨论】:
我有一个建议给你:
@property (nonatomic, strong) NSArray *tableItems;
@property (nonatomic) NSInteger hideIndex;
在 didSelectRowAtIndex 方法中添加 UITableView 委托方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Store index of row to hide.
self.hideIndex = indexPath.row;
}
创建你的操作方法
- (void) doOperation {
// Remove index from table datasource.
@try {
NSMutableArray *tempArray = [NSMutableArray arrayWithArray:self.tableItems];
[tempArray removeObjectAtIndex:self.hideIndex];
self.tableItems = [NSArray arrayWithArray:tempArray];
tempArray = nil;
[self.tableView reloadData];
}
@catch (NSException *exception) {
NSLog(@"Handle exception");
}
}
这样在下次重新加载 UITableView 时将显示剩余的单元格。并删除您选择的单元格。
【讨论】: