2012-07-10 102 views
0

我有一個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.'不知道看到這是否與我的問題,如果是這樣,如果有辦法解決它。

非常感謝,

回答

1

這是正常的,一個模式的看法應該是這種方式工作

Apple Documentation

呈現視圖控制器的能力是你有在您的處置工具用於中斷當前工作流程並顯示一組新的視圖。通常,應用會將視圖控制器呈現爲臨時中斷,以便從用戶獲取關鍵信息。但是,您也可以使用提供的視圖控制器在特定時間爲您的應用程序實現備用界面。

在您的didSelectRowAtIndexPath方法,你可以使用類似

YourAppNameDelegate *appDelegate = (YourAppNameDelegate *)[[UIApplication sharedApplication] delegate]; 
[appDelegate tabBarController].selectedIndex = 0; 
+0

謝謝盧卡斯,那效果很好。但是,我將如何通過我的方法'[passThisAlong:@「id」]'。在之前它像'FirstViewController * firstViewController = [[FirstViewController alloc] initWithNibName:@「FirstView」bundle:[NSBundle mainBundle]]; [firstViewController passThisAlong:@「id」];'我將如何使你的例子工作? – Nathan 2012-07-10 15:03:38

+0

我會在第一個viewController上創建一個屬性,然後你可以設置它的屬性。 – Lucas 2012-07-10 15:05:55

+0

或者你可以使用代表團,我認爲這將是整潔的 – Lucas 2012-07-10 15:06:27

1

現在的模式視圖以這種方式工作。爲什麼你不能使用基於標籤的應用程序?

+0

只是嘗試和喜歡的人,如果我做'[自我presentModalViewController:smartPicViewController動畫:是];'它不顯示的TabBar – Nathan 2012-07-10 15:09:16

+2

當前模式的看法會利用整個屏幕。你可以去基於Tab +導航的應用程序:-) – Nina 2012-07-10 15:11:03

相關問題