How can I stop my custom UITableViewCell backgroundImage from being stretchable?

Up vote 2 down vote favorite share g+ share fb share tw.

If I create a background image for my table cell in the init method of my UITableViewCell subclass, the image comes out exactly how I drew it, and tableView:heightForRowAtIndexPath: simply adds a gap around it. But if instead I create the background image in my tableView's tableView:cellForRowAtIndexPath: method and set it, changing the cell height will now stretch the image. I need to create the background views in the cellForRowAtIndexPath method, as the background changes for different rows.

How can I make my image's size fixed again? Iphone cocoa-touch uitableview uitableviewcell uiimageview link|improve this question asked Apr 20 '11 at 11:41Ric Levy400113 84% accept rate.

Put it here - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundView. ContentMode = UIViewContentModeCenter; }.

Makes no difference, I'm afraid. – Ric Levy Apr 20 '11 at 12:12 I've checked my edited answer in practice and it worked, do you get notifications for edited answers? – tsakoyan Apr 20 '11 at 12:50 Sorry - just saw it.

There doesn't seem to be any notification for edited answers. It works perfectly now. Thanks!

– Ric Levy Apr 20 '11 at 16:19.

You could create something with: UIView *cellBackView = UIView alloc initWithFrame:CGRectZero autorelease; ; cell. BackgroundView = cellBackView; My guess is the backgroundView gets strechted automatically, but you could make sure the image isn't stretched on that view by setting a width and height. This way, you can do whatever you like with that view.

I've given this a try but it doesn't seem to do anything :( – Ric Levy Apr 20 '11 at 12:12.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions