2011-04-22 108 views
0

我如何定義和檢查我的應用程序中alreadySelectedSpecificTab和viewControllerNotToAllow。任何人都會給我一個例子。iPhone應用程序的標籤欄

真的我想做點什麼。喜歡。當選擇第二個選項卡時,如果我們選擇第二個選項卡未被選中,則只選擇要重新定位的選項卡。

那就是爲什麼我使用下面的代碼。

請回復

- (BOOL)tabBarController:(UITabBarController *)tabBarControllers shouldSelectViewController:(UIViewController *)viewController 
{ 
if(alreadySelectedSpecificTab) 
     { 
      if([viewController isEqual:viewControllerNotToAllow]) 
        return NO; 
     } 
     return YES; 
} 
+0

我沒有明白你想要做什麼? – SJS 2011-04-22 05:45:46

回答

0

創建類

一些性質和保持你想要什麼樣否認跟蹤和你不想要什麼拒絕。

id currentlySelected; //This will hold the address of the selected view 
id dontAllowSelection; //This will hold the address of the Denied view 


- (BOOL)tabBarController:(UITabBarController *)tabBarControllers shouldSelectViewController:(UIViewController *)viewController 
{ 
    if (dontAllowSelection != nil &&    //If it is nil, we will skip it. 
     dontAllowSelection == viewController) //If the selected view is Denied return NO 
    { 
     return NO; 
    } 
    currentlySelected = viewController; 

    if (currentlySelected == someViewIWantToDisableOtherFor) //Any logic can go here to enable the Denied View. 
    { 
     dontAllowSelection = anotherViewIWantDisabled; //Set my denied view. 
    } 
    else 
    { 
     dontAllowSelection = nil; //Unsed the Denial. 
    } 

    return YES; 
} 
+0

坦克親愛的。 – Naresh 2011-04-22 07:27:13

+0

一定要接受答案,如果它解決了你的問題。 – 2011-04-22 17:23:05

相關問題