iphone - UITableViewCell 中的 UILabel autoresizingMask

标签 iphone objective-c ios uiview uilabel

我将 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 移动到单元格的右侧?

最佳答案

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

关于iphone - UITableViewCell 中的 UILabel autoresizingMask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7685105/

相关文章:

ios - UICollectionCell 位置问题

ios - 如何在加载之前将数据从选项卡栏 Controller 传递到每个选项卡?

iphone - 获取在 iOS UIFont 中追踪字符的路径

iphone - 如何在启用分页的情况下在 UIScrollView 中延迟加载 100 多个页面?

ios - 不同的 UITableViewCell 类型对齐

iphone - 执行 FMDB 插入查询但未在数据库中插入数据

iphone - 如何检测 UITableView 中某个单元格的双击?

ios - 从带有方向的 ios 应用程序打开苹果 map 应用程序

objective-c - 在 Objective-C 中,在 main 之前调用什么?

ios - GLKit 离屏渲染到纹理不工作