UiButton / IBAction - link from a RootView to mainView in Storyboard
- by webschnecke
I try to call the main ViewController on my storyboard. In my app there is a additional .h, .m file with no xib or storyboard.
In this .m file T craeted a button:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(home:)forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
NSLog(@"Home-Button line 645");
This button should link to my main ViewController in the Storyboard. The view has the identifier HauptMenu. I got no error, but the view doesnt change to my main ViewController. What is wrong?
- (IBAction)home:(id)sender {
NSLog(@"Button was tapped");
ViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"HauptMenu"];
NSLog(@"1");
[viewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
NSLog(@"2");
[self.navigationController pushViewController:viewController animated:NO];
[viewController release];
NSLog(@"3");
}