[問題] cell內label重覆
想請教的問題是,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)];
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 42.75.100.65
推
03/20 17:39, , 1F
03/20 17:39, 1F
推
03/20 21:27, , 2F
03/20 21:27, 2F
推
03/21 01:54, , 3F
03/21 01:54, 3F
→
03/21 01:55, , 4F
03/21 01:55, 4F
→
03/21 08:44, , 5F
03/21 08:44, 5F
→
03/21 08:46, , 6F
03/21 08:46, 6F
→
03/21 08:47, , 7F
03/21 08:47, 7F
→
03/21 08:48, , 8F
03/21 08:48, 8F
→
03/21 08:49, , 9F
03/21 08:49, 9F
※ 編輯: greatroy 來自: 42.75.100.65 (03/21 08:50)
→
03/21 15:53, , 10F
03/21 15:53, 10F
→
03/22 12:05, , 11F
03/22 12:05, 11F
→
03/22 12:06, , 12F
03/22 12:06, 12F
→
03/22 12:07, , 13F
03/22 12:07, 13F
→
03/22 12:07, , 14F
03/22 12:07, 14F
→
03/22 12:07, , 15F
03/22 12:07, 15F
→
03/22 12:08, , 16F
03/22 12:08, 16F
→
03/22 12:09, , 17F
03/22 12:09, 17F
→
03/22 12:09, , 18F
03/22 12:09, 18F
→
04/02 12:05, , 19F
04/02 12:05, 19F