想请教的问题是,Label重复产生造成画面重叠,
要如何解决?
谢谢
目前方法是:
为避免重复产生Label,在cellForRowAtIndexPath里
先把所有Label砍光,再产生Label,但实际只砍到textLabel,
而自订的Label在循环里却找不到。
for (UIView *item in [cell subviews]) {
if ([item isKindOfClass:[UILabel class]]) {
[item removeFromSuperview];
}
}
if (indexPath.row == 1) {
UILabel *subTitle = [[UILabel alloc] initWithFrame:rect];
[subTitle setText:[NSString stringWithFormat:@"%@", _buyDate]];
[cell addSubview:subTitle];
[cell.textLabel setText:@"购入日期"];
[cell setAccessoryType:(UITableViewCellAccessoryDisclosureIndicator)];
}