Reputation: 6109
Below is how I initialize the style for a cell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
.................................................
.................................................
// Set size for imageView
CGRect frame = self.imageView.frame;
frame.size.width = 16;
frame.size.height = 16;
self.imageView.frame = frame;
}
return self;
}
However, after setting an image to imageview of a cell, the image is stretching now. The size of original is 24x24.
How can I make an image look shape ?
Upvotes: 1
Views: 541
Reputation: 21726
Try not to use imageView property of the cell, but create your own imageview and add it
UIImageView *myImageView = [[UIImageView alloc] initWithImage:neededImage];
myImageView.frame = CGRectMake(0,0,16,16);
[self addSubview:myImageView];
[myImageView release];
The original problem is that imageView property is If an image is set, it appears on the left side of the cell, before any label.
So cell stretches it as it is used to behave.
Upvotes: 2