2011-04-22 3 views
0

내 애플리케이션 에서 alreadySelectedSpecificTab 및 viewControllerNotToAllow를 정의하고 확인할 수있는 방법은 무엇입니까? 누구든지 저에게 한 가지 예를 들게합니다.아이폰 애플리케이션 (탭바)

Actuly 뭔가하고 싶습니다. 처럼. 두 번째 탭을 선택하면 그 시간에 두 번째 탭을 선택하지 않으면 리마 탭만 선택됩니다.

그 이유는 다음 코드를 사용했기 때문입니다.

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

정확히 무엇을하고 싶지 않은가요? – SJS

답변

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

+0

문제가 해결되면 답변을 수락하십시오. –

관련 문제