想請教的問題是,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)];
}