New to iOS dev. Kindly correct me if i am wrong?
I have a UIWindow, and rootviewcontroller is :
@interface ViewController : UIViewController
{
IBOutlet UIButton *but;
}
@property (nonatomic, strong) UIButton *but;
-(IBAction) butButtonPressed;
@end
ie: If i make this Viewcontroller as a root view controller, the UIView that is available in the ViewController is displayed. Understood.
I have created a new class inherited from UIViewController, and along with its .xib file.
So xib file name is : view1.xib,
My Objective is to display this view when the button is pressed.
Now i have created a button and button press invokes butButtonPressed. Inside of butButtonPressed, i did the following.
myViewController *vcontroler = [[ViewController alloc] initWithNibName:@"view1" bundle:nil];
[self.view.window addSubview:vcontroler.view];
Application crashes. What am i doing wrong ? Kindly point out.