我尝试在故事板上调用主要的ViewController
。在我的应用程序中,还有一个额外的.h
,.m
文件,没有xib或storyboard。UiButton/IBAction - 从RootView到故事板中的mainView的链接
在这个.m文件牛逼craeted一个按钮:
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");
这个按钮应该链接到我的故事板主视图控制器。该视图具有标识符HauptMenu。我没有错误,但视图不会改变到我的主ViewController。哪里不对?
- (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");
}
谢谢!!!!!我拥有它! – webschnecke
但有一个问题更多;-)我使用MainStoryboard_iphone和MainStoryboard_ipad。我只想使用一个.h和.m文件。这是可以改变的,或者我该怎么做? – webschnecke
查看我的编辑 – Kevin