私はカスタムセルでuitableviewを持っています。TableViewの各セルに同じデータセットが設定されています
cellForRowAtIndexPath
メソッドでは、コアデータから値を取得して表示します。
データを一意に表示する必要がありますが、問題は、tableviewの各セルが同じデータセットを表示していることです。
後は
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@""];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:nil];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
self.productAmountTextLabel = [[UILabel alloc]init];
NSManagedObject *device = [self.devices objectAtIndex:indexPath.row];
self.productAmountTextLabel.text = [device valueForKey:@"amount"];
self.productAmountTextLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:10];
tableView.tableFooterView = [UIView new];
cell.layer.borderWidth = 1.0;
cell.layer.cornerRadius = 10;
cell.layer.borderColor = [UIColor blackColor].CGColor;
[cell.contentView addSubview:self.productAmountTextLabel];
return cell;
}
量ラベルは、DBから最初の値のみを取得し、すべてのセルの最初の値を表示し、私のcellForRowAtIndexPath
方法です。どうすればこれを整理できますか?
ivarでラベルを参照しないでください。ローカル変数を使用するだけで、このマサドの中にフッターを作成しないでください – Andrea
私のコードを参考にして詳細を教えてください。ありがとう –
self.productAmountTextLabelの代わりにcell.textLabelを直接使用する – Arun