UiButton / IBAction - link from a RootView to mainView in Storyboard
Posted
by
webschnecke
on Stack Overflow
See other posts from Stack Overflow
or by webschnecke
Published on 2011-11-17T15:39:41Z
Indexed on
2012/03/23
5:30 UTC
Read the original article
Hit count: 212
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");
}
© Stack Overflow or respective owner