Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 710
Ben Zotto Avatar asked Jan 23 '10 04:01

Ben Zotto


2 Answers

40x40

UITableViewCell's imageView fit to 40x40

Need to make imageView filled in 40x40... I am using SDK 3.0 with build in "Cell Objects in Predefined Styles"...

like image 165
David Sowsy Avatar answered Oct 17 '22 19:10

David Sowsy


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.

like image 35
Jeff Avatar answered Oct 17 '22 19:10

Jeff