我在UIViewController
內有UITableViewController
。雖然這個表視圖控制器是唯一涉及到的,但當用戶點擊一行時,它只是推送視圖。然而,自從我將它移動到UIViewController
中的兩個之後,行的突然突然沒有任何作用。如何顯示包含我的UIViewController的UITableViewController的新視圖?
我已經tried searching around我不是第一個遇到這個問題,但沒有答案符合我的情況或者問題沒有工作答案。該鏈接是我發現的最接近的,但我不使用故事板 - 我使用單獨的XIB。
那麼如何從視圖控制器中的視圖控制器推新視圖?
要回顧一下:
這裏是我有什麼,它採取用戶到一個新的屏幕工作得很好!
// Normal table behavior, as illustrated by [another question][2]. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { SomeView *detailViewController = [[SomeView alloc] initWithNibName:@"SomeView" bundle:nil]; // Pass the selected object to the new view controller. [self.navigationController pushViewController:detailViewController animated:YES]; }
現在我有視圖 - 控制在一個視圖中的屬性 - 與上面的代碼,這對於tableviewcontroller,而不是在「主」視圖中的文件,不會導致新的屏幕再次出現!
感謝您的意見!這裏有一些代碼來闡明我的場景。
控制器內的控制器。這是我用來測試概念的測試項目中的一個文件。在這種情況下,我有一個tableview控制器內的tableview控制器。
@interface SimpleTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> // This is the controller within the controller @property IBOutlet SecondTableViewController *secondTableController; @property IBOutlet UITableView *secondTable;
我
SecondTableViewController
有這個有趣的一點。- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here. Create and push another view controller. UIViewController *detailViewController = [[UIViewController alloc] initWithNibName:@"SimpleNonTableViewController" bundle:nil]; // ... // Pass the selected object to the new view controller. [manualViewControllerParent.navigationController pushViewController:detailViewController animated:YES]; }
用戶與被掛接到SimpleTableViewController
相互作用的圖。這樣,SecondTableViewController
就是「在」SimpleTableViewController
之內。如果您想了解更多詳情,請隨時發表評論!
我把我的測試/概念項目放在github上。 https://github.com/hyliandanny/TableViewCeption
您是否試圖推送已經被推送過的視圖控制器? – rooster117
你是什麼意思「在一個UIViewController中?它是一個子視圖控制器嗎? – rdelmar
@ rooster117在這種情況下,不是,現在顯示的屏幕是唯一通過這個表達到的 – Danny