2011-04-22 140 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

相关问题