我有一個iPhone應用程序,在我所有的視圖上都使用了一個tabbar。 此外,我的第一個視圖控制器沒有navigationBarController,但我的第二個視圖,以及tabbar。presentViewController不顯示tabbar
我的第二個視圖控制器是一個tableview,當我點擊其中一個單元格時,我想要帶到第一個視圖控制器(通過它傳遞一個參數)。
我已經嘗試了幾種處理方法,這些方法都適用,但不要。
secondViewController.m
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]];
[firstViewController passThisAlong:@"id"];
//[self presentViewController:firstViewController animated:YES completion:nil]; //1
[self.navigationController pushViewController:firstViewController animated:YES]; //2
//[self.tabBarController presentViewController:firstViewController animated:YES completion:nil]; //3
[firstViewController release];
firstViewController = nil;
所以你可以在上面看到,我試過3種不同的獲取到的第一個視圖控制器的方法。 第二個加載第一個視圖,在第二個視圖內向下鑽取,因爲它使nagigationBarController(即使第一個視圖沒有一個)與第二個視圖的後退按鈕保持一致。
其他兩個彼此做同樣的事情。哪一個是第一個視圖(沒有導航欄),但是,沒有tabbar,第一個視圖的內容已經向上移動了tabbar的高度,在它的位置只是黑色。
我希望這一切都有道理。我希望能夠從我的第二個視圖去選擇某個表格中的某個單元格時,我的第一個視圖就好像我點擊了tabbar中的圖標。
我的文檔 'On iPhone and iPod touch, the presented view is always full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property.'
不知道看到這是否與我的問題,如果是這樣,如果有辦法解決它。
非常感謝,
謝謝盧卡斯,那效果很好。但是,我將如何通過我的方法'[passThisAlong:@「id」]'。在之前它像'FirstViewController * firstViewController = [[FirstViewController alloc] initWithNibName:@「FirstView」bundle:[NSBundle mainBundle]]; [firstViewController passThisAlong:@「id」];'我將如何使你的例子工作? – Nathan 2012-07-10 15:03:38
我會在第一個viewController上創建一個屬性,然後你可以設置它的屬性。 – Lucas 2012-07-10 15:05:55
或者你可以使用代表團,我認爲這將是整潔的 – Lucas 2012-07-10 15:06:27