我有一个方法,我有一个(渲染的)UITableViewCell*。我想知道整个单元格的宽度/框架。
cell.frame
似乎不起作用 - 它给了我一个随机单元格的框架。我得到的最接近的是 cell.contentView.frame
但它不包括 accessoryView
覆盖的区域(参见 http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7 )。 cell.contentView.superview.frame
也不起作用 - 它在任意位置给我一个框架,就像 cell.frame
一样。
cell.contentView.width
+ cell.accessoryView.width
可以工作,除非辅助 View 是 UITableViewCellAccessoryNone
关于如何在所有情况下获取 UITableViewCell
的整个框架/宽度的任何想法?
最佳答案
试试这个,
NSLog(@"Cell Width = %f",cell.frame.size.width);
NSLog(@"Cell Height = %f",cell.frame.size.height);
它将显示当前单元格的宽度和高度。
关于iphone - 获取整个 UITableViewCell 的宽度/框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6825960/