UILabel autoresizingMask在UITableViewCell中

Tim*_*aev 2 iphone objective-c uiview uilabel ios

我将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];
Run Code Online (Sandbox Code Playgroud)

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

Mar*_*ich 5

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