在自带的uitableviewcell上面加内容时,如果在nav的二级界面,那么从三级界面多返回几次,就会发现加的内容重叠,原因就是二级界面没有销毁掉,那么加的内容没有删除,第二次返回的时候会又加一遍。如何解决呢?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier=@"mydatacell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==nil) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
for (id subview in cell.contentView.subviews) {
[subview removeFromSuperview];
// return cell;
}
//加上上面的for代码,就可以了
//这里可以往自带的cell上面随意加东西了