开发者

UITableView with fixed image background

开发者 https://www.devze.com 2023-01-16 00:42 出处:网络
Sorry but I found no clear answer on that. I have an iphone app with a tab bar and a UINavigationController in each tab.

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; // <-- ne开发者_如何学Pythoned 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 ?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号