如何在tableview单元格iphone中设置textLabel的位置

iOS*_*dev 1 iphone xcode objective-c uitableview

  • 在我的表视图中,我使用的是UITableviewCEllStyleValue1:

 if (cell == nil) 
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];

     cell.textLabel.text = @"Hai";
                cell.detailTextLabel.text = @"Hello";

        cell.detailTextLabel.textAlignment = UITextAlignmentLeft;
        cell.textLabel.textAlignment = UITextAlignmentLeft;
        return cell;

        }
Run Code Online (Sandbox Code Playgroud)
  • 这里显示两个标签文本labe,detailTextLabel.

  • 但不是我想要的位置.

  • 我需要从单元格的起始位置显示Textlable(0,0)并且immidiate右侧位置是detailTextlabel两个标签之间没有间隙.

  • 我需要一个不使用Allignment的解决方案.该怎么办?

Jak*_*b W 8

创建自定义UITableViewCell子类并覆盖该layoutSubviews方法.