У меня есть следующий код, который просто создает пользовательский UITableViewCell. Я создаю динамическую высоту строки, это дорого? Любой способ оптимизировать это?
Я также изменяю размер рамки одного из моих ярлыков в cellForRow. Есть ли способ оптимизировать это?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
MessageCell *cell = (MessageCell*)[self tableView:tableView cellForRowAtIndexPath:indexPath];
return cell.bodyLabel.bounds.size.height + 30;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MessageCell";
MessageCell *cell = (MessageCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[MessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.usernameLabel.text = [[items objectAtIndex:indexPath.row]valueForKey:@"user_login"];
cell.bodyLabel.text = [[[items objectAtIndex:indexPath.row]valueForKey:@"body"]gtm_stringByUnescapingFromHTML];
[Utils alignLabelWithTop:cell.bodyLabel];
cell.dateLabel.text = [Utils toShortTimeIntervalStringFromStockTwits:[[items objectAtIndex:indexPath.row]valueForKey:@"created_at"]];
[cell.avatarImageView reloadWithUrl:[[items objectAtIndex:indexPath.row]valueForKey:@"avatar_url"]];
return cell;
}