Objective c 切换为不带故事板的TabBarView
我有一个ConnectionViewController,当我单击Test按钮时,我想切换为tabViewController 在my ConnectionViewController中:Objective c 切换为不带故事板的TabBarView,objective-c,uitabbarcontroller,Objective C,Uitabbarcontroller,我有一个ConnectionViewController,当我单击Test按钮时,我想切换为tabViewController 在my ConnectionViewController中: - (IBAction)testButton:(id)sender { TabBarViewController *tabBarViewController = [[TabBarViewController alloc] init]; [self presentViewController
- (IBAction)testButton:(id)sender {
TabBarViewController *tabBarViewController = [[TabBarViewController alloc] init];
[self presentViewController:tabBarViewController animated:YES completion:nil];
}
但是当我点击我的测试按钮时,TabBarView是黑色的,没有任何内容
我能做些什么来解决这个问题?我想要一个模态序列,而不是推
Thx很多
[编辑]:解决方案是使用类似CustomSegue.m的类创建自定义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];
}
选项卡栏控制器为黑色的原因是它没有任何要显示的ViewController。在显示tabBarController.ViewController属性之前,需要设置该属性。假设您希望显示一个tabBarViewController,第一个选项卡上显示viewController1,第二个选项卡上显示viewController2
tabBarViewController.viewControllers = @[viewController1, viewController2];
谢谢!但现在我得到了这个错误:`NSInternalInconsistencyException',原因:`无法将标识符为ConferenceTableCell的单元格出列-必须为标识符注册nib或类,或在序列图像板中连接原型单元格'`而当我将序列图像板的其他测试按钮从我的ConnectionView分离到TabBarView时,没有问题:/