7

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!

Martin
  • 377
  • 3
  • 6
  • 12

1 Answers1

-1

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

self.tableview.backgroundColor = [UIColor clearColor];
Codezy
  • 5,540
  • 7
  • 39
  • 48
  • A very good tuturial is here http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html – Sharjeel Aziz May 18 '10 at 20:46
  • 1
    Thanks! How do I add a UIImageView behind the UITableView in interface builder? – Martin May 18 '10 at 21:13
  • 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 May 18 '10 at 21:17
  • 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 May 18 '10 at 21:24
  • 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 May 20 '10 at 16:07
  • 1
    How do i put a UIImageView behind a UITableView in a UITableViewController? It doesn't seem possible. – Maciej Swic May 26 '14 at 08:43