image inside tableviewcell problem

Discussion in 'iOS Programming' started by chhoda, Nov 25, 2008.

  1. macrumors 6502

    Joined:
    Oct 25, 2008
    #1
    Hi All,

    I am setting images inside uiTableviewcell by calling [cell setImage:img]

    I want to reduce the image dimensiona in side the cell.. I tried doing

    [[UITableViewCell alloc] initwithframe:cgrectmake(0, 0, img.size.width / 2, img.size.height / 2)]

    but the image does not get reduced.

    i tried returning the row height as img.size.height / 2 but it makes the images overlapped.

    so what to do ?

    how togo about it ?

    chhoda
     
  2. macrumors newbie

    Joined:
    Oct 27, 2008
    #2
  3. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #3
    thanks

    thanks but, i tried customizing my tablecell, but ran into other problems...

    like I am keeping an array and using its count as no of rows to display..

    when i change no of array items, i create the view again and display it. [i had tried just updating the array and calling setNeedsLayout and setNeedsDisplay , but they did not work...]

    when i put break point in noofrows function, it shows 5 item,

    but comes into the function cellForRowAtIndexPath only 3 times..

    I changed array counts from 3 to 5

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //NSLog(@"row #%d, %d", indexPath.row, indexPath.section);
    static NSString *chIdentifier = @"ChannelIdentifier";

    ChannelCell *cell = (ChannelCell *)[tableView dequeueReusableCellWithIdentifier:chIdentifier];
    if(cell == nil) {
    Channel *ch = [arrChannels objectAtIndex:indexPath.row];
    cell = [[[ChannelCell alloc] initWithFrame:CGRectZero withImage:ch.image reuseIdentifier:chIdentifier] autorelease];
    }

    return cell;
    }

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    //NSLog(@"Section %d", section);
    return [arrChannels count];
    }
     
  4. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #4
    image is not resizing inside the cell

    see... i went through whole article and it seems they are not resizing the image at all. they are showing image in their original size. I think it is not possible to resize the image view or image inside a table cell..
     
  5. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #5
    resizing image in table cell

    see... i went through whole article and it seems they are not resizing the image at all. they are showing image in their original size. I think it is not possible to resize the image view or image inside a table cell..
     
  6. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    I believe you will want to look into using the drawInRect: method of UIImage, which scales it as needed to fit.
     
  7. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #7
    got it

    in fact i was doing a mistake. i was doing cellview.image = img instead of doing cellview.imageview.image = img


    sorry :)
     

Share This Page