0

好的,這是我的問題:我的應用程序在iPhoneOS屏幕底部的標籤欄中顯示類別。在顯示MORE按鈕之前,這隻允許5個類別。我有超過25(請不要回答這個問題:「重新考慮你的申請...等等」 - 這是粗魯地說過的,它們是食物,飲料等類別,不能改變)。我想讓用戶把他們的最愛放在主頁上。由於編輯頁面上的空間限制,Apple moreNavigationController編輯系統僅允許重新排列20個標籤欄項目。這是不夠的,所以我需要實現我自己的編輯屏幕。我將rightBarButtonItem設置爲零,並創建了我自己的。使用NSLog,我可以看到點擊「編輯」按鈕時發生「點擊」,但我無法使用pushViewController進行推送。什麼都沒發生。我認爲這與我正在處理的navigationController有關......但我不確定。 ps:這一切都發生在我的應用程序委託,它既充當UITabBarControllerDelegate & UINavigationControllerDelegate。單擊NavBar上的按鈕單擊moreNavigationController - 無法pushviewcontroller

我試着做到以下幾點:

- (void)navigationController:(UINavigationController *)navigationController_local willShowViewController:(UIViewController *)viewController_local animated:(BOOL)animated 
{ 

    UIViewController * currentController = navigationController_local.visibleViewController; 
    UIViewController * nextController = viewController_local; 

// Do whatever here. 
NSLog(@"Nav contoller willShowViewController fired\n'%@'\n'%@'\nThere are currently: %d views on the stack\n",currentController,nextController,[self.navigationController.viewControllers count]); 

if ([nextController isKindOfClass:NSClassFromString(@"UIMoreListController")]) 
{ 
    UINavigationBar *morenavbar = navigationController_local.navigationBar; 
    UINavigationItem *morenavitem = morenavbar.topItem; 
    morenavitem.rightBarButtonItem = nil; 
    NSLog(@"Is a UIMoreListController\n"); 

    UIBarButtonItem *editTabBarButton = [[UIBarButtonItem alloc] 
      initWithTitle:@"Edit" 
      style:UIBarButtonItemStylePlain 
      target:self 
      action:@selector(editTabBar:)]; 

    morenavitem.rightBarButtonItem = editTabBarButton; 
    [editTabBarButton release]; 
} 


} 

此作品放置一個編輯按鈕在屏幕的右上角 - 模仿蘋果的外觀和感覺...但點擊該按鈕時,您無法退出該更多導航控制器。

我已經嘗試了很多東西。 UIAlerts的工作等等,但推動(或彈出 - 甚至彈出到根視圖)堆棧上的視圖控制器沒有。

- (void) editTabBar:(id)sender { 
NSLog(@"clicked edit tabbar\n"); 
NSLog(@"Total count of controllers: %d\n",[self.navigationController.viewControllers count]); 

TabBarViewController *tabBarViewController2 = [[TabBarViewController alloc] initWithNibName:@"TabBarView" bundle:nil]; 
    [email protected]"Edit Tab Bar"; 
    [self.navigationController pushViewController:tabBarViewController2 animated:YES]; 
    [tabBarViewController2 release]; 

NSLog(@"finished edit tabbar\n"); 

} 

如果單擊moreNavigationController的顯示頁面上的編輯按鈕,你得到的日誌條目像預期,(這是奇怪)堆棧攀登的意見 - 但沒有發生改變頁面。我將其標記爲不使用正確的導航控制器...但我迷失於如何找到使用哪一個。

這也是一個奇怪的。在編輯功能,如果我只是這樣做:

- (void) editTabBar:(id)sender { 
self.tabBarController.selectedIndex = 0; 
} 

它不帶我回家(至tabbarcontroller 0)

但是這樣做:

- (void) editTabBar:(id)sender { 
    [self.navigationController popToRootViewControllerAnimated:YES]; 
    } 

不起作用。

moreNavigationController是否有一些特殊的質量與系統的其他部分相連?

回答

2

我會嘗試從頭開始重新實現整個「更多」功能。換句話說,將四個主頁標籤存儲在您的用戶默認值中,並添加一個虛擬的第五個標籤,切換到您自己的更多視圖控制器堆棧的完整重新實現。

你甚至可以編寫一個輕量級的UITabBarController子類來處理這個。

+0

我正在嘗試...我也有問題 - 我會在這裏發佈鏈接:http://stackoverflow.com/questions/2609916/how-to-pushviewcontroller-to-a-viewcontroller-存儲-在-A-tabbaritem – Jann 2010-04-09 18:32:22

0

UITabBarController是邪惡的,所以如果MoreController有一些特殊的屬性,我也不會感到驚訝。

我已經成功攔截shouldSelectViewController中的更多控制器來更改數據源;您可能能夠在那裏找到一些解決方法。

PS我傾向於同意,您可以考慮重新設計您的應用程序,以便您不需要連接到選項卡欄的無限數量的viewControllers只需選擇類別;使用帶有單個可滾動自定義視圖的工具欄,您可能會有更好的運氣。當然,如果這真的是爲您的應用選擇類別的最佳方式。