View Full Version : image inside tableviewcell problem
chhoda
Nov 25, 2008, 03:42 AM
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
Svinja
Nov 25, 2008, 04:36 AM
it is very easy to make UITableView subclass, it is explained very well in this tutorial.
http://icodeblog.com/2008/09/02/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-2/
This way you can make Table view cell look like you want it.
chhoda
Nov 27, 2008, 06:44 AM
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];
}
chhoda
Nov 28, 2008, 03:30 AM
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..
chhoda
Nov 28, 2008, 03:44 AM
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..
dejo
Nov 28, 2008, 11:12 AM
I believe you will want to look into using the drawInRect: method of UIImage, which scales it as needed to fit.
chhoda
Dec 2, 2008, 12:07 AM
in fact i was doing a mistake. i was doing cellview.image = img instead of doing cellview.imageview.image = img
sorry :)
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.