Я уверен, что это будет одна из тех вещей, когда кто-то указывает на что-то действительно очевидное, что я делаю, но я не могу ради жизни найти проблему. В основном у меня есть массив строк, и я загружаю текст из массива в свои uitableviewcells, как и когда это необходимо. Проблема возникает, когда я начинаю прокручивать и по какой-то причине ячейка № 6, т. Е. В 7-й ячейке отображается текст из позиции массива 0 поверх текста из позиции массива 6, а когда я прокручиваю вверх, текст в ячейке 0 отстает или под (я не могу точно сказать) текст из позиции массива 6 !! ?? Я понятия не имею, как я это делаю. Вот мой код:
NSMutableArray *titles1 = [[NSMutableArray alloc]initWithCapacity:10];
[titles1 insertObject:[NSString stringWithFormat:@"0"] atIndex:0];
[titles1 insertObject:[NSString stringWithFormat:@"1"] atIndex:1];
[titles1 insertObject:[NSString stringWithFormat:@"2"] atIndex:2];
[titles1 insertObject:[NSString stringWithFormat:@"3"] atIndex:3];
[titles1 insertObject:[NSString stringWithFormat:@"4"] atIndex:4];
[titles1 insertObject:[NSString stringWithFormat:@"5"] atIndex:5];
[titles1 insertObject:[NSString stringWithFormat:@"6"] atIndex:6];
[titles1 insertObject:[NSString stringWithFormat:@"7"] atIndex:7];
[titles1 insertObject:[NSString stringWithFormat:@"8"] atIndex:8];
[titles1 insertObject:[NSString stringWithFormat:@"9"] atIndex:9];
self.secretTitles = titles1;
[titles1 release];
// Настройка внешнего вида ячеек табличного представления.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
}
// Configure the cell.
cell.selectedBackgroundView.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
-(void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
secretName = [[UILabel alloc]initWithFrame:(CGRectMake(10, 8, 100, 30))];
secretName.backgroundColor = [UIColor clearColor];
secretName.textColor = [UIColor whiteColor];
secretName.font = [UIFont boldSystemFontOfSize:18];
secretName.shadowColor = [UIColor colorWithRed:0./255 green:0./255 blue:0./255. alpha:0.7];
secretName.shadowOffset = CGSizeMake(0, 2.0);
secretName.text = @"";
NSLog(@"row = %d", indexPath.row);
secretName.text = [self.secretTitles objectAtIndex:indexPath.row];
[cell.contentView addSubview:secretName];
}
Может кто-нибудь, пожалуйста, избавь меня от моих страданий. Большое спасибо
Jules