Question

What's the default size for the UIImage in a UITableViewCell?

I want to put a UIImage in the left side of each row in a UITableView. This is pretty standard, and is supported directly by UIKit. But putting in a (large) image causes all kinds of wonkiness, so presumably I'm supposed to scale the thing correctly myself. But none of the docs give a default size for this image using the standard out of the box views-- I'm surprised.

Others on SO indicate that 44 is the default height of a row (What is the default height of UITableViewCell?) Is 44x44 the "default" image size?

Thanks!

 45  34741  45
1 Jan 1970

Solution

 3

I'm on Xcode 4.6.3 building for iOS 6.1. I tried 2 sizes of image assigned to imageView of the UITableViewCell: 48x48 and 128x128 pixels. This was run in the iOS Simulator (iPad).

In the UITableViewDelegate, I put the following line in tableView:didSelectRowAtIndexPath: and put a break point right after it.

UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];

In lldb, I get this output:

(lldb) po cell
$0 = 0x0751a720 <UITableViewCell: 0x751a720; frame = (0 88; 180 44); text = 'widget'; autoresize = W; layer = <CALayer: 0x751a6f0>>
(lldb) po cell.imageView
$1 = 0x0751a1e0 <UIImageView: 0x751a1e0; frame = (0 0; 43 43); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x751a1b0>>

The only conclusion I can reach based on this evidence is that the default image size is not 40x40.

2013-08-07