views:

340

answers:

1

Given: I have a bit of a "pop up" view that I put over my tableView within my UITableViewController. I put it there like this:

[self.navigationController.view addSubview:self.hoverView];

Problem: I cannot see this hoverView when I add a tableView footer view. Seemingly unrelated yes?

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
[self.tableView.tableFooterView addSubview:someLabel];

These appear to be mutually exclusive. I can have one, but not the other. To see what's going on, I print subview descriptions like so:

for (UIView *sub in self.navigationController.view.subviews)
{
    NSLog([sub description]);
}

When the table footer view is added, this code prints nothing. Otherwise, I see the expected output of some navigationController internal views. What did I miss?!

+1  A: 

Don't add the hoverView to the UINavigationController's view. Instead of using a UITableViewController, use a UIViewController whose view contains a UITableView as a subview. (See here for details of how to implement the rest of the UITableViewController's functionality in your UIViewController). Then add your hoverView to that view, i.e., make it a sibling of the UITableView, but a later sibling so it appears above it.

This may not solve your problem but I'd say it's your best bet: a UINavigationController is not designed to have its view manipulated directly, it's designed to have view controllers pushed onto its stack and add subviews to its view accordingly.

hatfinch