В моем приложении я добавляю 3 UILabel к каждой ячейке представления таблицы следующим образом.Добавление элементов NSArray в представление содержимого UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ShowMoreCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [self getCellContentView:CellIdentifier];
return cell;
}
- (UITableViewCell *)getCellContentView:(NSString *)cellIdentifier
{
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier] autorelease];
cell.backgroundColor=[UIColor clearColor];
for(int j = 0; j < 3; j++)
[cell insertSubview:[items objectAtIndex:j] atIndex:j];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
Здесь элементы является NSMutableArray
и имеет элементы UILabel. Я пытаюсь добавить три labels
в каждом cell
. Но он отображает 3 labels
только в последней строке.
Я делаю что-то неправильно здесь?
Благодаря
вы не повторно используете ячейку, а создаете новую, каждый раз вызываете cellForRowAtIndexPath, что, я думаю, вызовет у вас больше проблем с памятью. – Joshua