我嘗試在故事板上調用主要的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