How can reserve space for an image I don't yet have in a default-style UITableViewCell
I'm trying to use a UITableViewCell with UITableViewCellStyleDefault to display a cell that will eventually have an image in its imageView (after loading it from the interwebs.)
However, when I try to set the the cell's imageView.frame
to the correct size, the cell just doesn't use reserve the space for the image view (the text is left-aligned rather than having a blank space where the image开发者_如何学编程 will go.)
Is there a way to programmatically have the image view be a certain size without having an image in it?
I'd rather avoid subclassing UITableViewCell or including a blank image.
It looks like if you want to use the imageView frame itself to reserve the space you are going to need a blank image. In the past I have used a loading image as a placeholder. Maybe you can try adjusting the detailTextLabel either by padding with space until the image loads or adjusting its position. I would recommend a blank/loading image.
imageView Returns the image view of the table cell. (read-only)
@property(nonatomic, readonly, retain) UIImageView *imageView
Discussion
Returns the image view (UIImageView object) of the table view, which initially has no image set. If an image is set, it appears on the left side of the cell, before any label. UITableViewCell creates the image-view object when you create the cell.
精彩评论