What's the default size for the UIImage in a U

2020-02-18 03:35发布

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!

2条回答
Emotional °昔
2楼-- · 2020-02-18 03:37

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.

查看更多
手持菜刀,她持情操
3楼-- · 2020-02-18 03:43

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"...

查看更多
登录 后发表回答