iphone - 如何调整 cell.textLabel 的大小?

标签 iphone objective-c ios ipad uitableview

我想调整 UITableViewCell 的默认 textLabel 的大小,因为我在行的右侧显示图像。我试过这段代码,但它不起作用,我不明白为什么。

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
         //...
         cell.textLabel.frame = CGRectMake(5, 5, 100, 50);
         //...
    }

最佳答案

你应该使用自定义标签

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

if (cell == nil) 
{

    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];

    UILabel *Lbl = [[UILabel alloc]initWithFrame:CGRectMake(75.0f, 4.5f, 360.0f, 20.0f)]; 
    [cell.contentView addSubview:Lbl];
    [Lbl release];
}

关于iphone - 如何调整 cell.textLabel 的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7551940/

相关文章:

iphone - 是否可以设置允许的最大 ios 版本

iphone - 如何为 UIWebView 实现 NTLM 身份验证?

html - Json 服务以 HTML 形式返回

ios - 如何在 IOS 中处理多个远程通知点击

ios - 如何在不使用 webview IOS 7 的情况下玩直播电视

ios - 使用 Facebook 登录时出错

iphone - 操作系统版本中的“位置”(地理定位)支持

ios - 子类未找到父类(super class)接口(interface)的 Objective-c 错误

ios - ICViewPager 顶部和底部有奇怪的空格

ios - 应用麦克风访问