Reputation: 1263
i have some strange Problem. I use the Interface Builder to create a Custom TableCell with three Labels and one UIImageView:
I want that the Cell has a little space to the TableView (the blue border), so i put an extra View inside the Cell. As you can see the UIImageVIew is realy small and not higher than two labels, but when i run my code on the device the UIImageView is high as the white View and even covers the Label a little bit. The only thing i do in my Code is:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier1 = @"CustomCellReuseID";
GTEventCustomCell *eventCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (eventCell == nil) {
eventCell = [[GTEventCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1];
}
// Configure the cell...
[eventCell.imageView setImage:[UIImage imageNamed:@"heart.png"]];
.
.
.
What´s wrong?
Upvotes: 0
Views: 565
Reputation: 15335
This will fix your problem:
eventCell.imageView.contentMode = UIViewContentModeScaleAspectFit;
Upvotes: 1
Reputation: 399
I just think you should change your properties in the right panel.
You can also desactivate autolayout constraints and, to be sur to place your items at the good place, set them programmatically.
example : at the top of your file :
#define X_Cell_Padding 10
#define Y_Cell_Padding 10
in cellForRow methods :
[[cell yourImageView] setFrame : CGRectMake(X_Cell_Padding, Y_Cell_Padding, yourImageView.frame.size.width, yourImageView.frame.size.height)];
don't forget to create a custom cell class with your IBOutlet yourImageView and to set this class for the cell in your storyboard / xib
Upvotes: 0
Reputation: 163
I hope you have not missed the auto layout constraints for the objects inside the custom cell.
If not select a label/view in toolbar Editor > Resolve Auto Layout issues > add missing constraints
and change the auto layout constraint as you need it.
Upvotes: 0