Reputation: 9923
Here's what im having: I have a TableView with custom UITableViewCell, it's loading the data from an MutableArray.
In my cellForRow: i call the code to draw a subview with the data from the array, when i scroll down and scroll up, that subview appear very wrong, but every label appear to be correct...
I have tried many answer around google but all doesnt solve it, i even put the subview to the array but doesnt work too,sorry i cant post image yet :(
NSMutableArray *mintHistoryList = //Array of Epin objects
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
// Configure the cell...
EPinObject *data;
if (indexPath.row < self.mintHistoryList.count && [[self.mintHistoryList objectAtIndex:indexPath.row] isKindOfClass:[EPinObject class]])
{
data = [self.mintHistoryList objectAtIndex:indexPath.row];
UILabel *pinGeneratedDateLabel = (UILabel *)[cell viewWithTag:100];
pinGeneratedDateLabel.text = data.pinGeneratedTime;
UILabel *pinNumberLabel = (UILabel *)[cell viewWithTag:101];
pinNumberLabel.text = data.pinCode;
UILabel *pinOriginalLabel = (UILabel *)[cell viewWithTag:102];
pinOriginalLabel.text = [NSString stringWithFormat:@"%@%@", [Common currencyFloatRemake:data.pinOriginalAmount],[Common currencyCodeToSymbol:data.pinCurrencyCode]];
pinOriginalLabel.adjustsFontSizeToFitWidth=YES;
pinOriginalLabel.minimumScaleFactor=0.5;
UILabel *pinLeftLabel = (UILabel *)[cell viewWithTag:103];
pinLeftLabel.text = [NSString stringWithFormat:@"%@%@ left", [Common currencyFloatRemake:data.pinLeftAmount],[Common currencyCodeToSymbol:data.pinCurrencyCode]];
pinLeftLabel.adjustsFontSizeToFitWidth=YES;
pinLeftLabel.minimumScaleFactor=0.5;
//THIS PART
UIView *circleView = (UIView *)[cell viewWithTag:104];
[circleView addSubview:[Customview alloc]initWithOriginal:data.pinOriginalAmount andLeft:data.pinLeftAmount];
}
The array does not change, other label also does not change, only the subview is not correct
Correct: https://drive.google.com/file/d/0BwtBKpSMH_eHUWRfMkpzOTFaTkE/view?usp=sharing
Scroll down and up: https://drive.google.com/file/d/0BwtBKpSMH_eHWkxmeDNGQUJvdnM/view?usp=sharing
Upvotes: 1
Views: 457
Reputation: 1557
I Think problem is here
UIView *circleView = (UIView *)[cell viewWithTag:104];
[circleView addSubview:[Customview alloc]initWithOriginal:data.pinOriginalAmount andLeft:data.pinLeftAmount];
When you will reuse cell it will contain 2 circleView... You should remove the previous one, or reuse circleView itself
PS Images is not available for me, I receive error 403
Upvotes: 1