私の問題と似ているが、全く同じではない投稿がいくつか見つかりました。uitableviewcellのtableviewの重複行
私のアプリでは、ユーザーはいくつかのuitableviews間を移動して、希望の結果にドリルダウンすることができます。ユーザーが前進、後進、後進などをすると、行が再描画され、書き直され、テキストが大胆で大胆になります。
投稿の中には、cellforrowatindexpath
メソッドの中で、私が行を作成する方法に関連するものがあることがわかりました。
ユーザーがテーブルビュー間を前後に移動するたびに行が再作成/再描画されないようにするために必要なことはありますか?下のコードに何かを追加するか、viewwillappearメソッドに何かを追加する必要がありますか(現在、テーブルのビューに「reloaddata」がありますが、役立たないようです)?ここで
は私のコードです:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UILabel *label = [[[UILabel alloc] init] autorelease];
label.font = [UIFont fontWithName:@"Arial-BoldMT" size:20];
label.frame = CGRectMake(10.0f, 10.0f, 220.0f, 22.0f);
label.textColor = [UIColor blackColor];
label.backgroundColor = [UIColor clearColor];
label.opaque = NO;
label.text = [mapareaArray objectAtIndex:indexPath.row];
[cell.contentView addSubview:label];
CustomCellBackgroundView *bgView = [[CustomCellBackgroundView alloc] initWithFrame:CGRectZero];
bgView.borderColor = [UIColor clearColor];
bgView.fillColor = [UIColor whiteColor];
bgView.position = CustomCellBackgroundViewPositionSingle;
cell.backgroundView = bgView;
return cell;
}
ありがとうございます。大きな助け。 これについての最後の質問です。プログラミングのバックグラウンドはありませんので、ヘッダーファイルで#defineを使用することで何を意味するのかはわかりません。これを行うための構文は何ですか?私は前にそれを見て、ヘッダーに#define kMyTagを入れようとしましたが、これはうまくいきません...私はあなたが値にkMyTagを定義する必要があると仮定していますが、これを行うための構文が何であるかはわかりません。手伝ってくれますか? – SKayser