In a subclass of UITableViewCell, I override layoutSubviews because I need to calculate frames from multiple subzones. The basis for all my calculations is the width of the content representation. Here's what the beginning of my layoutSubviews implementation looks like:
- (void) layoutSubviews { [super layoutSubviews];
I started testing this in a grouped table format in an iPhone simulator. It is assumed that the cell consists only of what is inside the content view, i.e. I turned off all the bizarre stuff around. In particular, I turned off accessory viewing by setting the accessory type to UITableViewCellAccessoryNone . Because of this, the appearance of the accessories is hidden, although its border / frame properties still report a 20/20 size.
Based on all this and the following simple illustration, I expected the width of the content representation in the above code snippet to be reported as 300.
<----------- screen width = 320 -----------> +------------------------------------------+ | | | <--- content view width = 300 ---> | | +--------------------------------+ | |<-->| table view cell |<-->| | 10 +--------------------------------+ 10 | | | | [...] |
But this is not so, the actual information on the width of the content presentation is 270!
A little research shows that 30 missing points consist of a) 20 widths of the auxiliary view and b) 10 intervals between the presentation of the content and the accessory. I tried to set the size of the accessory view to 0/0, the effect was that now the width of the content view is 290. A little better, but still 10 points. I also tried setting the accessoryView property to nil , but the view is simply recreated [super layoutSubviews] .
Finally, the question is: is there a way to really disable the appearance of the accessory so that it is not included in the calculation of the width of the content view? Alternatively, would it be safe to skip the [super layoutSubviews] call and just calculate the width yourself?
source share