【问题标题】:UILabel autoresizingMask in UITableViewCellUITableViewCell中的UILabel autoresizingMask
【发布时间】:2011-12-02 20:40:43
【问题描述】:

我将 UILabel 添加到简单的 UITableViewCell,但是当我将设备旋转到横向时,UILabel 不会移动到右侧,即使 myLabel.autoresizingMask = UIViewAutoResizingFlexibleRightMargin; 它位于 UITableViewCell 的中间。 在纵向模式下,myLabel 位于 UITableViewCell 的右侧。这是代码:

myLabel = [[UILabel alloc] initWithFrame:CGRectMake(252, 12, 60, 20)];
myLabel.font = [UIFont fontWithName:@"Helvetica" size:11];
myLabel.textColor = tableViewCell.detailTextLabel.textColor;
myLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
myLabel.highlightedTextColor = [UIColor whiteColor];
myLabel.text = video.duration;
myLabel.tag = 999;
[cell.contentView addSubview:durationLabel];
[myLabel release];

当我将设备旋转到横向模式时,如何将此 UILabel 移动到单元格的右侧?

【问题讨论】:

    标签: iphone objective-c ios uiview uilabel


    【解决方案1】:

    如果要移动到右边,需要设置UIViewAutoresizingFlexibleLeftMargin(因为左边距会增加)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      相关资源
      最近更新 更多