Reputation: 2741
I have aded a new View in my app, its just a .xib file On button click i am calling this new view... AS
UIViewController *newView = [[UIViewController alloc] initWithNibName:@"Welcome" bundle: [NSBundle mainBundle]];
[self.view addSubview:newView.view];
It call successfully the new view. I have set some labels and button newView that are shown on button click. now the problem is this, 1- i have to send or pass some data to newView from main and also 2- when i connect a UILabel using CONTROL Drag in interface builder on selecting File's Owner Of newView with desired Label it gives me error on button click
'[<UIViewController 0x89d05b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Users.'
'User' is the UILabel type variable In my .h file that is declared as
@property(nonatomic ,retain) IBOutlet UILabel *Users;
any suggestion or help would be appriciated
Upvotes: 0
Views: 86
Reputation: 41256
You're creating a UIViewController instead of your custom UIViewController subclass. What you should be using is:
MyViewController* vc = [[MyViewController alloc] initWithNibFile:...]
Also note that if you're using child view controllers, you should be calling addChildViewController with the newly created view controller so that the UIViewController methods are properly propagated to the child view controller.
One last note, none of this will work reliably before iOS 5, as up to that point child view controllers were strongly advised against.
It also sounds like you're not using a subclass for the child view controller, if you add properties or actions, you have to use a subclass.
Upvotes: 1