こんにちはGuysさんがiOS Appで働いていて、ユーザーのデータがUITableview
に表示されています。最初のユーザーにとってはうまく動作しますが、UIbutton
のようにクリックして次のユーザーデータを表示したい場合は、次のユーザーデータを表示する前に各ラベルに空の文字列を割り当てていますが、UITableviewCell
は前のユーザーデータを消去しません。私のコードはここにありますUITableviewCellはデータをクリーニングしていませんか?
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *headLablel,*textLabel,*subLabel,*sharedActLbl;
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
headLablel=[[UILabel alloc]init];
headLablel.tag=11;
[cell.contentView addSubview:headLablel];
textLabel=[[UILabel alloc]init];
textLabel.tag=12;
[cell.contentView addSubview:textLabel];
subLabel=[[UILabel alloc]init];
subLabel.tag=13;
[cell.contentView addSubview:subLabel];
助けていただければ幸いです。ありがとう
ドンサブビューを追加したり、カスタム 'UITableViewCell'を使い分けたり、手作業でそれを掃除したりしないでください(私の意見ではかなり醜いです)。 'UITableVIewCell'は**再利用されています**。 – Larme
'cellForRowAtIndexPath'のセルにコンポーネントを追加する場合は、毎回このコンポーネントを削除して再ビルドする必要があります。 – jose920405