Я использую Grouped UITableView и добавляю UITableViewCells две UILabel's и добавляю их в contentView ячейки.Я также реализую режим редактирования в моем приложении на этом UITableView.
Я использую lblDetail.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;
, чтобы уменьшить ширину текста, чтобы красная кнопка удаления, отображаемая в режиме редактирования, не закрывала мой текст.
Теперь я вижу, когда я прокручиваютаблица не находится в режиме редактирования, метки отображаются два раза, как если бы она находилась в режиме редактирования и одновременно в режиме редактирования.
Это код:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
CGRect DetailLabelFrame = CGRectMake(52, 25, 200, 35);
CGRect TitleLabelFrame = CGRectMake(52, 5, 200, 25);
lblDetail = [[UILabel alloc]init];
lblTitle = [[UILabel alloc]init];
lblDetail.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;
lblTitle.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;
lblDetail.frame = DetailLabelFrame;
lblDetail.lineBreakMode = UILineBreakModeWordWrap;
lblDetail.backgroundColor = [UIColor clearColor];
lblDetail.numberOfLines = 2;
lblTitle.frame = TitleLabelFrame;
lblTitle.backgroundColor = [UIColor clearColor];
lblTitle.frame = TitleLabelFrame;
[lblDetail setFont:[UIFont fontWithName:@"Arial" size:14]];
[lblTitle setFont:[UIFont fontWithName:@"Arial-BoldMT" size:15]];
lblDetail.textAlignment = UITextAlignmentRight;
lblTitle.textAlignment = UITextAlignmentRight;
lblTitle.text = @"054-9700583";
lblDetail.text = @"שאלה:במה אפשר לעזור לך?";
[cell.contentView addSubview:lblDetail];
[cell.contentView addSubview:lblTitle];
cell.imageView.layer.masksToBounds = YES;
cell.imageView.layer.cornerRadius = 5.0;
cell.imageView.image = [UIImage imageNamed:@"girl.png"];
[lblDetail release];
[lblTitle release];
return cell;
}