Is anyone familiar with how to initialize/load a sub-view programmatically within an existing view which is part of a viewcontroller.
Here is the entire situation:
MyView.nib - created using interface builder. This nib has a UIView and another UIView [subview] within it. It uses MyViewController.
If I assign the class mysubview via interface builder. It works smoothly, no problemo.
But what I am interested in doing is loading the subview programmatically within a view controller, after some logic is done in the main view. (i.e. after I call a web service and depending on the results then I may want to load the subview). If assigning it directly in interface builder, it loads automatically, which defeats purpose of what i want to do.
I was figuring maybe I can load it via assigning the class similar to below within the viewcontroller:
myview1 = mysubview;
Obviously it is not working...
MySubView.h
Code:
@interface MySubView : UIWebView {
}
@end
MySubView.M
Code:
#import "MySubView.h"
@interface MySubView (Private)
- (void) loadMap;
@end
@implementation MySubView
//------------------------------------------------------------------------------
- (void) didMoveToSuperview {
// this hook method is used to initialize the view; we don't want
// any user input to be delivered to the UIWebView.
self.userInteractionEnabled = NO;
self.scalesPageToFit = NO;
self.autoresizingMask =
UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
[self loadMap];
}
MyViewController.h
Code:
@interface MyViewController : UIViewController {
IBOutlet UIView *mySubView1;
}
@end