I have the following action that gets called when a button gets clicked. The log message gets printed yet, the view doesn’t change. This function is in a UIViewController.
Any ideas what I am doing wrong? Why isn’t the new view being displayed with a red background?
- (void)viewDidLoad
{
[levelButton2 addTarget:self action:@selector(clickButton) forControlEvents:UIControlEventTouchUpInside];
//MORE CODE
}
- (void) clickButton
{
NSLog(@"Clicked Button");
UIViewController *myViewController = [[UIViewController alloc] init];
myViewController.title = @"My First View";
myViewController.view.backgroundColor = [UIColor redColor];
//to push the UIView.
[self.navigationController pushViewController:myViewController animated:YES];
//[self.navigationController pushViewController:nextController animated:YES];
}
Then after go into the MyFirstController.m file and
I hope it will help you.