She*_*lam 1 iphone objective-c uitableview ios
我有以下代码,只是创建一个自定义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;
}
Run Code Online (Sandbox Code Playgroud)
[items objectAtIndex:indexPath.row]还可以观看使用乐器的WWDC视频,了解如何找到绘图代码杀死性能的位置.今年有一些(有些,不是全部)非常棒的会议.
| 归档时间: |
|
| 查看次数: |
1918 次 |
| 最近记录: |