我想創建一個使用故事板的UITableView,但我來到的東西可能很簡單,但我不知道如何解決它。 首先讓我指出,我知道故事板的一個侷限性在於,您將不得不挖掘故事板以查找有關您所擁有的視圖的信息並將其鏈接到應用程序代理。 我已經創建了我的可變數組和我將在應用程序委託的表中使用的信息,現在我想將該UITableView引用到應用程序委託。層次結構是這樣說參考視圖使用故事板的應用程序委託
- 首先我有根認爲,一旦你點擊一個按鈕,它會重定向到第二視圖
- 第二視圖裏面還有另外一個,一旦你按下它,它就會按鈕將您重定向到UINavigationController
- UINavigationController包含UITableView。
因此,您可以看到在導航控件和UITableView之前有兩個視圖。
這裏是我嘗試使用的代碼,但它不工作
UIViewController *viewController = (UIViewController *)self.window.rootviewController;
// The next line refers to the second view but does not work at all
UIViewController *secondView = [[UIViewController viewController] objectAtIndex:1];
//Then the following line is to redirect from the second view to the navigation controller
UINavigationController *navigationController =[[secondView viewController] objectAtIndex:0];
//Then is the table view
BuildingsViewController *buildingsViewController = [[navigationController viewControllers] objectAtIndex:0];
上面的代碼不起作用。誰能幫幫我嗎? 非常感謝
您好,感謝您的答覆。 我做了你所說的並且只爲numberOfRowsInSection工作。對於cellForRowAtIndexPath有一些錯誤,根本不起作用 – user1015777 2012-02-26 10:50:49
什麼部分不起作用?關鍵點是演示如何通過應用程序上的單例訪問器訪問包含表格視圖控制器中的表格模型數據的數組,以訪問應用程序委託。 – gamozzii 2012-02-26 23:40:14