UIImage problem to set size

Discussion in 'iOS Programming' started by MACloop, Apr 5, 2011.

  1. macrumors 6502

    May 18, 2009
    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!
  2. macrumors 68030


    Sep 2, 2008
    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.
  3. thread starter macrumors 6502

    May 18, 2009
    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 :)

Share This Page