をスクロールした後、アップミキシング私はUITextField
、UILabels
とUIButtons
でカスタムUITableViewCell
を作成しました。 UITextField
に値を入力してスクロールすると、それが消えて別のランダムなセルに表示されます。同じ問題が私のUIButton
で発生します。それを押すと、状態は変化しますが、下にスクロールすると消えます。ここでカスタムUITableViewCellsのUITextFieldには、
は私cellForRowAtIndexPathです:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"produktCell";
//NSString *CellIdentifier = [NSString stringWithFormat:@"produktCell %d",indexPath.row];
ProduktTableViewCell *cell =(ProduktTableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSLog(@"wird neu erstellt");
cell = [[ProduktTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.produktnameLabel.text = [managedObject valueForKey:@"produktname"];
if ([[managedObject valueForKey:@"vondatum"] length] > 1){
cell.vonDatumLabel.text = [managedObject valueForKey:@"vondatum"];
cell.bisDatumLabel.text = [managedObject valueForKey:@"bisdatum"];
}else {
cell.vonDatumLabel.text = dateString;
cell.bisDatumLabel.text = dateString1;
}
cell.datumButton.tag = indexPath.row;
cell.warenkorbButton.tag = indexPath.row;
cell.menge.tag = indexPath.row + 437812;
cell.mengeLabel.text = [managedObject valueForKey:@"mengelabel"];
cell.produktnameLabel.tag = indexPath.row +22333;
cell.mengeLabel.tag =indexPath.row;
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
NSLocale *german = [[NSLocale alloc] initWithLocaleIdentifier:@"de_DE"];
[formatter setLocale:german];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setMinimumFractionDigits:2];
[formatter setMaximumFractionDigits:2];
NSNumber *firstNumber = [managedObject valueForKey:@"preis"];
cell.preisLabel.text = [formatter stringFromNumber:firstNumber];
return cell;
}
編集:私はテキストフィールドに私の問題を修正しました。私はちょうど方法を削除する:
/*- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[[self.tableView superview] endEditing:YES];
}*/
私のボタンにはまだ問題があります。
私はこの行をコメントすると同じ動作をします。テーブルビューはまだ混ざります。 –
私の編集をチェックしてください。 – Peres
私はそれを試しましたが、(セル== nil)に入ることができません。テーブルビューは空でNSLogは呼び出されません。 –