views:

103

answers:

2

Hi all,

Sorry but I found no clear answer on that. I have an iphone app with a tab bar and a UINavigationController in each tab. The interface is built with Interface Builder, and in the first tab there is a UITableView. I have prepared the xib with main view (A) containing a table (T) and an image (IMG) background behind (image as subview of main view). Later I assigned UITableViewController as owner. This is where problems start. In IB if I connect view to A I got a runtime error telling me that controller cannot find a table. If I connect controller view to T everything works fine, except that IMG is not shown.

The only solution I found is to create a new xib holding A and IMG with a UIViewController as owner. Then create a xib holding T only and UITableViewController as owner, correctly connected to T. Then in viewDidLoad of the UIViewController:

iptc = [[IPPlantsTableViewController alloc] initWithNibName:@"IPPlantsView" bundle:[NSBundle mainBundle]];

iptc.navigator=self.navigationController; // <-- need this

[self.view addSubview:iptc.view];

And this works, except that the table view seems to not know anything about navigationController, therefore detail view mechanism is not working, unless I set a property for it in UITableViewController. I also run in to some other problems, for example all the logic for adding/deleting/creating rows to table has to be handled in UIViewController and sent to UITableViewController.

Is there another way for having a fixed image in a table view ?

+1  A: 

Mmmm

I will be honest i HATE Interface Builder ;-) so I can't help you about this.

But to set a fixed image in the background of a UITableView you should : - set background color of the UITableView to [ UIColor clearColor ] (and maybe the background of the cell too) - set and uiimageview below the uitableview view that contains the image :)

In that way this should work.

But without xcode project I can't help you more ^^

Good luck

Vinzius
+1 interface builder is the devil
Thomas Clayson
YEAH ! all against IB xD I totally agree
Vinzius
Altough there are time when is necessary and faster to create view programmatically, I rather prefer to create template with IB. There's much control on element positioning, graphic, ecc...
Leonardo
A: 

UITableViewController is a convenience class; you can equally just use UIViewController and implement the correct callbacks.

In OS 3.2+, you can just set UITableView.backgroundView. If IB doesn't let you do this, you can do it in code instead.

Alternatively, you might be able to wire up the view and tableView outlets differently, unless tableView just does (UITableView*)self.view.

tc.
Thanks... I have succesfully managed to convert UITableViewController to a normal UIViewController and magically the background appear. However I have a last annoying problem, the top and bottom cells I made with IB just show a black background below the rounded corner (like a .gif without transparency). If I declare a color for UITableView instead of clearColor, the problem disappear, but of course I cannot see the background.
Leonardo
Does setting UITableView.backgroundView work?
tc.
What do I have to set for backgroundView ? Is it not enough to clearColor the table view ?
Leonardo
I switched to plain table rather than a grouped one, and built two ui custom cells more, one for the header and one for the footer. So the problem is temporaly solved.
Leonardo