views:

390

answers:

1

In iPhone I need to set the background view of a UITableview. From 3.2 SDK I can in code use something like:

[self.tableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mycustombackground.png"]]];

But how can I do the same in interface builder? It would be great if I could just set the background view directly in interface builder. But can't seem to find this property, where is it?

Thanks!

+1  A: 

Add a UIImageView behind it, put the image in that and set the tableview to transparent:

self.tableview.backgroundColor = [UIColor clearColor];
Codezy
A very good tuturial is here http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
Shaji
Thanks! How do I add a UIImageView behind the UITableView in interface builder?
Martin
Drop a UIImageView on the view and use the layout send to back menu item, or place it after the tableview in the listing of objects under your view (in the window with file owner)
Codezy
Yes, I found this thread, they say the same thing: http://stackoverflow.com/questions/894875/how-can-i-set-the-background-of-uitableview-the-tableview-style-is-grouped-to But in my TableViewController.xib I only have: Files owner, First Responder, Table View. No View at all? So I'm not sure where to put the UIImageView?
Martin
Without having xCode nearby, here is what I would try in that case. Create a new uiimageView in code, add it to the tableview like [tableView addSubView:myImageView]; and call send to back on the image view.... That might do it, but again could not test that on my own.
Codezy