Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chhoda

macrumors 6502
Original poster
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
 
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];
}
 
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..
 
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..
 
I believe you will want to look into using the drawInRect: method of UIImage, which scales it as needed to fit.
 
got it

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


sorry 🙂
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.