2014-02-21 18 views
0

我在UIViewController的容器中創建了一個UITableViewController單擊某行時查看不會更改 - xcode ios

一切正常,直到我點擊一個單元格爲了查看用戶的信息。

當我點擊行應該去一個包含標籤的視圖,但它沒有這樣做(它停留在表的頁面上)。

我知道它調用下面的函數,因爲我把NSLog放在那裏,當我點擊一行時,它會顯示出來。

有人可以幫我嗎?謝謝!

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

{ 
    UINavigationController *tabController = [self.storyboard instantiateViewControllerWithIdentifier:@"TabNav"]; 
tabController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
[self.navigationController pushViewController:tabController animated:YES]; 

}

回答

0

我發現了這個問題!由於一些奇怪的原因,我不得不改變這些行:

UINavigationController * tabController = [self.storyboard instantiateViewControllerWithIdentifier:@「TabNav」]; tabController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self.navigationController pushViewController:tabController animated:YES];

爲了這些行:

的UIViewController *的viewController = [[UIStoryboard storyboardWithName:@ 「主」 束:無] instantiateViewControllerWithIdentifier:@ 「TabNav」]; [self presentViewController:viewController animated:YES completion:nil];

換句話說,它不承認self.storyboard ...不管怎樣,感謝您的幫助!

0

致電前:

[self.navigationController pushViewController:tabController animated:YES]; 

你必須在UINavigationController添加 - tabController到視圖層次結構。

//擴展

試試這個,:

 UINavigationController *tabController = [self.storyboard instantiateViewControllerWithIdentifier:@"TabNav"]; 
    [tabController willMoveToParentViewController:self]; 
    //try wit this line if this will not work 
    //tabController.view.frame = self.view.bounds; 
    [self.view addSubview:tabController.view]; 
    [self addChildViewController:tabController]; 
    [tabController didMoveToParentViewController:self]; 
    [self.navigationController pushViewController:tabController animated:YES]; 
+0

我該怎麼做?我的意思是,我對前一個視圖做了相同的過程,並且它工作正常... –

+0

查看編輯答案。 – Greg

+0

這個想法很有效,但由於表格在一個標籤中,當我使用它時,它會打開我在此標籤中調用的標籤欄。 –