我有一个ConnectionViewController,当我点击测试按钮时,我想切换到tabViewController。
In my ConnectionViewController:
- (IBAction)testButton:(id)sender {
TabBarViewController *tabBarViewController = [[TabBarViewController alloc] init];
[self presentViewController:tabBarViewController animated:YES completion:nil];
}
但是当我点击我的测试按钮时,TabBarView是黑色的,没有任何东西。
我能做些什么来解决这个问题?我想要modal segue,而不是push
Thx a lot
[EDIT]:解决方案是用CustomSegue这样的类创建一个自定义segue。
-(void) perform {
ConnectionViewController *src = (ConnectionViewController*) self.sourceViewController;
TabBarViewController *dest = (TabBarViewController*) self.destinationViewController;
[UIView transitionWithView:src.navigationController.view duration:0.2 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
[src presentViewController:dest animated:YES completion:NULL];
}
completion:NULL];
}
标签栏控制器是黑色的原因是它没有任何viewControllers来呈现。你需要设置tabBarController。属性。假设你想要呈现一个tabBarViewController,在第一个选项卡上有viewController1,在第二个选项卡上有viewController2。
tabBarViewController.viewControllers = @[viewController1, viewController2];