Home > DeveloperSection > Forums > How to customize image view of UITableViewCell in Xcode-4.6?
Eric Martell
Eric Martell

Total Post:9

Points:63
Posted on    February-02-2016 12:53 AM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 432  View(s)
Rate this:

My problem is in the imageView of UITableViewCell. I want to fit our images into the imageView of table view cell with same height/width and a text in the context view.
I was trying this code:

cell.imageView.image = ifg.groupImage;
cell.textLabel.text = ifg.groupName;

above code running perfectly but if the images are different width/size then it also same reflection displays in cell imageView, so that my question is how can display images with same width/height?
I am search it every where but can't find any easiest solution. Please help me.



Tarun Kumar

Total Post:210

Points:1614
Supported
Posted on    February-03-2016 12:59 AM

If you want to display image with same height/width in UITableViewCell, then you need to create custom UIImageView and add it in the contentView of table cell.
See the example:

// creating custom image view (imgView) with same height/width
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,55,55)];
imgView.backgroundColor = [UIColor clearColor];
// adding image into imgView
[imgView setImage:ifg.groupImage];
// at last add the imgView into cell content
[cell.contentView addSubview:imgView];

I hope it will be helpful for you.


Don't want to miss updates? Please click the below button!

Follow MindStick