iphone - 如何覆盖 UITableViewCell 中的 accessoryView 以更改其位置

标签 iphone ios uitableview

默认情况下,UITableViewCell 上的 accessoryView 位于单元格的最右侧。我正在对 UITableViewCell 进行子类化,以尝试更改此位置以将其移到更左侧,但是,它没有任何效果,它仍然在右侧。关于如何执行此操作的任何想法?

- (void) layoutSubviews
{
    [super layoutSubviews];
    self.accessoryView.frame = CGRectMake(100, self.accessoryView.frame.origin.y, self.accessoryView.frame.size.width, self.accessoryView.frame.size.height);
    self.accessoryView.layer.borderWidth = 1;
    self.accessoryView.layer.borderColor = [[UIColor redColor] CGColor];
}

enter image description here

最佳答案

在您的单元格子类中实现 layoutSubviews,首先调用 super,然后修改您想要更改的 subview 的框架。

关于iphone - 如何覆盖 UITableViewCell 中的 accessoryView 以更改其位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16779811/

相关文章:

iOS:我可以从表格 View 注册 textfieldDidBeginEditing 吗?

ios - 在 XCode Playgrounds 中注册单元重用标识符

iphone - 如何以编程方式隐藏选项卡栏,然后展开 View 以适合

iphone - iOS >4.0 中的 locationServicesEnabled 始终显示 UIAlert

ios - 在 TableView 中删除或重新排序单元格时的动画

ios - Apple 应用商店 IPV6 要求

ios - 细胞再利用初学者?点击一个单元格中的按钮会影响另一个单元格

iphone - 具有半透明选定背景的 UITableViewCell

iphone - 我的 iPhone 软件太慢了!

iphone - NSString "invalid summary"