Gold challenge background


#1

Hi,

I manged to put the background in, by adding the following to HomepwnerAppDelegate:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"bg" ofType:@"jpg"]; UIImage *tableBg = [UIImage imageWithContentsOfFile]; itemsViewController.tableView.backgroundColor =[UIColor colorWithPatternImage:tableBg];

(I tried putting it in ItemsViewController didLoad, and works as well)

My problem is that the background gets repeated behind each section (and in the simulator, behind each cell). I’ve tried to set the cells to have a clear background, but instead I lose the white, and all I see is the background image (the part that is repeating.) In other words, I have the same background starting and ending multiple times, instead of just once, behind everything.

How do I get rid of the background behind everything, except the main background? Am I doing the background wrong?


#2

Fixed it by adding the background image as an image view instead:

[code]-(void)viewDidLoad{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@“bg” ofType:@“jpg”];
UIImage *tableBg = [UIImage imageWithContentsOfFile];
UIImageView *backgroundImageView = [[UIImageView alloc]
initWithImage:tableBg];
[[self tableView] setBackgroundView:backgroundImageView];

}[/code]


#3

Even a little shorter:

-(void)viewDidLoad { UIImageView *bkg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]]; [[self tableView] setBackgroundView:bkg]; }