![](/img/trans.png)
[英]ios:Instatinate View Controller is not working(View Controller is not pushing)?
[英]iOS pushing view controller not working
我有一個uitabbarcontroller設置為窗口的根視圖。 標簽欄中的一個標簽設置為uitableviewcontroller的子類。 我正在嘗試做的是在觸摸其中一行時顯示詳細信息視圖,因此我實現了
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!detailViewController) {
detailViewController = [[ItemDetailViewController alloc] init];
}
[detailViewController setEditingArray:
[list objectAtIndex:[indexPath row]]];
[[self navigationController] pushViewController:detailViewController animated:YES];
}
在我的表控制器中,但是當我選擇行時,我的詳細視圖不會彈出。我添加了nslog以查看該函數是否觸發 - 但確實如此,但我的詳細視圖仍未顯示。 有任何想法嗎? 謝謝。
你沒有導航控制器( [self navigationController]
返回nil
)。 而不是將表視圖控制器作為選項卡的根,使選項卡的根成為包含表視圖控制器的導航控制器。 您現在可以從表視圖控制器中推送詳細控制器。
tableViewController
應放在NavigationController
。 我猜你在標簽欄里面創建了tableView
。
TableViewControllerSubclass* table = [[TableViewControllerSubclass alloc] init];
UINavigationController* tableNav = [[UINavigationController alloc] initWithRootViewController:table];
mainController = [[UITabBarController alloc] init];
mainController.viewControllers = [NSArray arrayWithObjects:tableNav,..., nil];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.