Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Views in One Nib (addSubview)
    text
    copied!<p>I'm trying to keep my code clean and keep the number of files down. I am using a UITableViewController and I would like to load another view on top of it. I thought this would be pretty simple: </p> <p>(1) create an IBOutlet in my .h file </p> <pre><code>@interface MyViewController : UITableViewController { ... UIView *downloadView; ... } ... @property (nonatomic, retain) IBOutlet UIView *downloadView; ... </code></pre> <p>(2) link it to my view in IB </p> <p>(3) do something like:</p> <pre><code>self.view = downloadView; </code></pre> <p>or</p> <pre><code>[self.view addSubview:self.downloadView]; </code></pre> <p>But that doesn't work for me. If I do </p> <pre><code>[self.tableView removeFromSuperview]; </code></pre> <p>Then the table view goes away but I don't know how to add my view from my nib. I'm doing everything for tableView programatically but I didn't think that would matter. And with UITableViewController subclassing UIViewController I thought it would be no problem using addSubview or something like that. What am I missing? This shouldn't be that hard right?</p> <p>Update: So if I do the following:</p> <pre><code>UIView *newView = [[UIView alloc] initWithFrame:self.view.frame]; newView.backgroundColor = [UIColor greenColor]; [self.view addSubview:newView]; </code></pre> <p>It does (mostly) what I want. So does this mean I'm messing something up with the way I'm connecting my view from IB? In IB I set the fileOwner's class to MyViewController and I make a connection between downloadView and the view that I created (in IB). That's all I should have to do right?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload