Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically Add a UIView to another
    text
    copied!<p>I am new to IOS, Xcode and MVC. I am on a steep learning curve and am failing with what I assume is a most basic task.</p> <p>I have a tabbed application with two tabs. Both tab views communicate with a web service and I want to add an image to each tab view, changing the image to indicate the connection state. </p> <p>So, I created a third .xib file with a controller class (IconViewController). I am hoping to add and remove an instance of this icon view in each of the tab views. </p> <p>Here is the pseudo code for my icon view:</p> <pre><code>@interface IconViewController : UIViewController { UIImageView *_icon; } @property (nonatomic) IBOutlet UIImageView *icon; - (void)setForBusy; - (void)setForOk; - (void)setForFail; </code></pre> <p>And implementation:</p> <pre><code>@implementation IconViewController @synthesize icon = _icon; -(void)setForBusy { // Set Busy Icon Image } -(void)setForOk { // Set Ok Icon Image } -(void)setForFail { // Set Fail Icon Image } </code></pre> <p>The icon IBOutlet is connected to an UIImageView on the accompanying xib file.</p> <p>Here is one of the root tab controllers:</p> <pre><code>#import "IconViewController.h" @interface TaboneViewController : UIViewController { IconViewController *_iconViewController; } @property (nonatomic) IBOutlet IconViewController *iconViewController; </code></pre> <p>and implementation:</p> <pre><code>@synthesize iconViewController = _iconViewController; - (void)viewDidLoad { [super viewDidLoad]; self.iconViewController = [[IconViewController alloc] initWithNibName:@"iconViewController" bundle:nil]; [self.view addSubview:self.iconViewController.view]; } </code></pre> <p>In the tabView xib Interface Builder I added an Object and made it a class type <em>IconViewController</em>. I connected the <strong>Icon View Controller Object->Reference Outlet</strong> to the <strong>File Owner->iconViewController Outlet</strong>.</p> <p>Running the project I get the error:<br> <strong>loaded the "iconViewController" nib but the view outlet was not set.</strong></p> <p>I have experimented with other connections but with no luck. It seems to me that my first connection should work but it doesn't. </p> <p>Any idea what I am misunderstanding? Is the principle good (loading an instance of third view into two root views)? If so, what outlet needs connecting?</p> <p>Many thanks, Polly</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