iOS 7 以不同方式布置 accessoryView 和 accessoryType?

标签 ios ios7 uitableview

还有其他人注意到 iOS 7 对自定义 accessoryView 的布局与内置 accessoryType 不同吗?

像这样:

enter image description here

最上面的是使用:

cell.accessoryView = cell.accessoryButton;

(其中 accessoryButton 是自定义的 UIButton)而第二个是使用:

cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

相同的代码、相同的应用程序、相同的 Xcode,但运行在 iOS 6 上:

enter image description here

这是 SDK 中的错误吗?或者我可以通过代码控制的东西?

最佳答案

如果您对 UITableViewCell 进行子类化,您可以在 layoutSubviews 中调整它

- (void)layoutSubviews {
    [super layoutSubviews];

    CGRect accessoryViewFrame = self.accessoryView.frame;
    accessoryViewFrame.origin.x = CGRectGetWidth(self.bounds) - CGRectGetWidth(accessoryViewFrame);
    self.accessoryView.frame = accessoryViewFrame;
}

关于iOS 7 以不同方式布置 accessoryView 和 accessoryType?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19015860/

相关文章:

ios - UITableView 更改特定单元格的背景颜色

ios - 使用新数据快速更新 UITableView

iphone - 从 iPhone 应用程序通过 WIFI 将文件导出到计算机 -

ios - PageViewController 页面指示器向上推 View

iOS 7/8 如何设置标签栏文字颜色

ios - 从嵌套在 TableViewCell 中的 CollectionViewCell 中呈现 ViewController

ios - 如何在 AfNetworking 3.0 中为请求添加 Headers?

ios - 使用 xib 和 tableView 的多个 View

php - 发布数据以从 IOS 中的 SQL 查询检索信息

ios - IndexPathForCell 和 IndexPathForRowAtPoint 崩溃