PDA

View Full Version : UIImage problem to set size




MACloop
Apr 5, 2011, 09:35 AM
Hello,
I do some download in my app where some of the data are images. In my app I save this data and create uiimages object where needed. Everything works fine so far. My problem is:
I have a custom tableViewCell class and in this class I have a UIImageView defined. No matter which size I set to this Uiimageview, the image put into it gets the height of the tablecell. I have tried to change the viewMode for the cell uiimageview content but without any luck so far. What can I do to actually get the images to be displayed with the size of the uiimageview it is added into...?

The images is created like this:
NSFileManager *fileManager = [[NSFileManager alloc]init];
UIImage *imgToUse = [[UIImage alloc] initWithData:[fileManager contentsAtPath:[dict objectForKey:@"data_path"]]];
[fileManager release];

After this the images is saved into a dictionary and in the table delegate method - (UITableViewCell *)tableView:(UITableView *)t cellForRowAtIndexPath:(NSIndexPath *)indexPath {
the image is added to the imageView, like this:
cell.imageView.image = [[self.imageDict objectForKey:@"some key here"];

Any Ideas? I do not understand why the cell height controls the image height? What am I doing wrong?
Thanks in advance!
MACloop



PhoneyDeveloper
Apr 5, 2011, 09:50 AM
The apple provided tableview cells have their own rules about size and positions of their labels and imageview. If you write a subclass and override layoutSubviews you can adjust the imageview according to your rules.

MACloop
Apr 6, 2011, 02:38 AM
The apple provided tableview cells have their own rules about size and positions of their labels and imageview. If you write a subclass and override layoutSubviews you can adjust the imageview according to your rules.

Ah, I did not know that! Thanks a lot - I will take a look at it in the documentation. I was assuming I could treat it like a normal image and that did not work :-)
MACLoop