2013-05-13 29 views
0

我有一個ConnectionViewController,當我點擊測試按鈕時,我想切換爲tabViewController。切換爲TabBarView沒有StoryBoard

在我ConnectionViewController:

- (IBAction)testButton:(id)sender { 

    TabBarViewController *tabBarViewController = [[TabBarViewController alloc] init]; 

    [self presentViewController:tabBarViewController animated:YES completion:nil]; 


} 

,但是當我在我的測試按鈕單擊時,TabBarView是黑色的,沒有任何東西。

我能做些什麼來解決這個問題?我想要一個模態賽車,而不是一個推動。

THX很多

[編輯]:的解決方案是創建定製賽格瑞與像CustomSegue.m一類具有此方法:

-(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]; 

} 

回答

0

之所以標籤欄控制器是黑色的是它沒有任何viewController呈現。在呈現它之前,您需要設置tabBarController.viewControllers屬性。假設你想要在第一個選項卡上顯示一個tabBarViewController,並在第二個選項卡上顯示viewController2。

tabBarViewController.viewControllers = @[viewController1, viewController2]; 
+0

Thx!但現在我得到這個錯誤: ''NSInternalInconsistencyException',原因:'無法使用標識符contestTableCell出隊的單元格 - 必須爲標識符註冊一個筆尖或類或連接故事板中的原型單元格' while when我將其他測試按鈕從我的ConnectionView連接到TabBarView,這是沒有問題的:/ – dramixx 2013-05-13 10:04:45