下にスクロールして上に戻ると、セルの UILabels で値が変化する UITableView があります。なぜこれが起こっているのかわかりません。
自分でサブクラス化したカスタム UITableViewCells を使用しています。
これは、エラーはないと思うので、ラベルにすべての値を入力しないコードのように見えますが、テーブルビューデリゲートメソッドまたはそのようなものを宣言する方法です。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
if (sortedItemsArray == nil) {
return 0;
} else
return [sortedItemsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomallCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomallCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.selectionStyle = UITableViewCellSelectionStyleGray;
if ([sortedItemsArray count] > 0) {
currentallDictionary = [sortedItemsArray objectAtIndex:indexPath.row];
NSNumber *tempDU = [currentallDictionary objectForKey:@"DU"];
NSInteger myInteger = [tempDU integerValue];
if (myInteger == 0) {
// NSLog(@"%@", currentallDictionary);
//assign vals to labels
NSString *areaString = [currentallDictionary objectForKey:@"area"];
if ((NSNull *) areaString != [NSNull null]) {
cell.areaLabel.text = areaString;
} else {
cell.areaLabel.text = @" ";
}
NSString *stageString = [currentallDictionary objectForKey:@"stage"];
if ((NSNull *) stageString != [NSNull null]) {
cell.stageLabel.text = stageString;
} else {
cell.stageLabel.text = @" ";
}
NSString *floorLabelString = [currentallDictionary objectForKey:@"floorNo"];
if ((NSNull *) floorLabelString != [NSNull null]) {
cell.floorLabel.text = floorLabelString;
} else {
cell.floorLabel.text = @" ";
}
NSString *floorDescLabelString = [currentallDictionary objectForKey:@"floorDesc"];
if ((NSNull *) floorDescLabelString != [NSNull null]) {
cell.floorDescLabel.text = floorDescLabelString;
} else {
cell.floorDescLabel.text = @" ";
}
//Buttons
tDxStateAString = [currentallDictionary objectForKey:@"tDxStateA"];
tDxStateBString = [currentallDictionary objectForKey:@"tDxStateB"];
tHasDxString = [currentallDictionary objectForKey:@"tHasDx"];
if ([tHasDxString isEqualToString:@"T"]) {
tDxQtyString = [currentallDictionary objectForKey:@"tDxQty"];
if ((NSNull *) tDxQtyString != [NSNull null]) {
cell.quantityALabel.text = tDxQtyString;
if (([tDxStateAString isEqualToString:@"T"]) && ([tDxStateBString isEqualToString:@"W"])) {
UIImage *checkedOnImage = [UIImage imageNamed:@"CheckedOn.png"];
[cell.DxfitButtonImage setImage:checkedOnImage forState:UIControlStateNormal];
} else if (([tDxStateAString isEqualToString:@"T"]) && ([tDxStateBString isEqualToString:@"R"])) {
UIImage *checkedOnDisabledImage = [UIImage imageNamed:@"CheckedOnDisabled.png"];
[cell.DxfitButtonImage setImage:checkedOnDisabledImage forState:UIControlStateNormal];
}else {
UIImage *checkedOffImage = [UIImage imageNamed:@"CheckedOff.png"];
[cell.DxfitButtonImage setImage:checkedOffImage forState:UIControlStateNormal];
cell.DxfitButtonImage.userInteractionEnabled = YES;
}
} else {
cell.quantityALabel.text = @" ";
cell.DxfitButtonImage.userInteractionEnabled = NO;
}
}
tStateAString = [currentallDictionary objectForKey:@"tStateA"];
tStateBString = [currentallDictionary objectForKey:@"tStateB"];
tHasInsString = [currentallDictionary objectForKey:@"tHasIns"];
if ([tHasInsString isEqualToString:@"T"]) {
tInsQtyString = [currentallDictionary objectForKey:@"tInsQty"];
if ((NSNull *) tInsQtyString != [NSNull null]) {
cell.quantityBLabel.text = tInsQtyString;
if (([tStateAString isEqualToString:@"T"]) && ([tStateBString isEqualToString:@"W"])) {
UIImage *checkedOnImage = [UIImage imageNamed:@"CheckedOn.png"];
[cell.allButtonImage setImage:checkedOnImage forState:UIControlStateNormal];
} else if (([tStateAString isEqualToString:@"T"]) && ([tStateBString isEqualToString:@"R"])) {
UIImage *checkedOnDisabledImage = [UIImage imageNamed:@"CheckedOnDisabled.png"];
[cell.allButtonImage setImage:checkedOnDisabledImage forState:UIControlStateNormal];
} else {
UIImage *checkedOffImage = [UIImage imageNamed:@"CheckedOff.png"];
[cell.allButtonImage setImage:checkedOffImage forState:UIControlStateNormal];
}
} else {
cell.quantityBLabel.text = @" ";
cell.allButtonImage.userInteractionEnabled = NO;
}
}
}
}
return cell;
}
細胞の複製を止める助けがあれば大歓迎です。