UIImage problem to set size

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

  1. macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #1
    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:
    Code:
    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
    Code:
    - (UITableViewCell *)tableView:(UITableView *)t cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    the image is added to the imageView, like this:
    Code:
    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
     
  2. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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

    Joined:
    May 18, 2009
    Location:
    Germany
    #3
    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
     

Share This Page