在我的第一个视图中,我有一个包含5条记录的UITableView。在UITableView中,细胞有两种不同的成分。一个UILabel是文本,另一个UILabel显示该单元格的值。
在选择此UITableViewCell时,用户被导航到另一个视图,在该视图中,我给出了一个选择器控制器,用于更改所选行的表视图中的第二个标签的值。我在-viewWillAppear上重新加载了UITableView数据,但是当我多次访问它时,这会与标签上的文本重叠。
谁能给我一个分层表格视图的相关示例,其中UItableViewCell的右侧部分依赖于从下一个视图中选择选择器。
发布于 2011-03-23 18:01:08
我认为您在每次重新装入表时都会在cell.contentView上添加标签,但并没有删除以前的标签。这就是重叠发生的原因。
试着去掉标签
- (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];
}
for (UIView * view in cell.contentView.subviews) {
[view removeFromSuperview];
view = nil;
}
// add your labels
}https://stackoverflow.com/questions/5403232
复制相似问题