1

사용자가 Tabbar 항목을 트리거하면 현재 모달보기 컨트롤러를 표시하려고합니다.탭 바에서 모달보기 컨트롤러를 트리거하는 가장 좋은 방법입니다.

나는 작동하지만 뭔가를하는 것이 가장 깨끗한 방법은 아닙니다. 또한 UITabBarItem이 선택 상태가되는 것을 방지합니다.

내가 한 것은이 메서드를 false로 설정하고 해당 메서드 본문에서 RootViewController를 통해 뷰 컨트롤러를 표시하는 것입니다.

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{ 
    UINavigationController *nvc = (UINavigationController*)viewController; 

TabBarItem을 강조 표시 할 수있는 더 명확한 구현 방법에 대해 알고 계십니까?

답변

0

MVC를 탭 막대에서 사용하는 방법 중 하나입니다. 탭 막대 항목을 강조 표시하려면 다음과 같이하십시오.

id currentlySelected; // 선택된 뷰의 주소를 유지합니다. id dontAllowSelection; //이 거부 된 뷰의 주소를 개최한다

  • (BOOL) tabBarController : (UITabBarController가 *) tabBarControllers shouldSelectViewController! (의 UIViewController *)의 ViewController

{

경우 (dontAllowSelection = nil & & // 0이면 건너 뜁니다. dontAllowSelection == viewController) // 선택한보기가 거부 된 경우 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; 

}

+1

회원님이 무슨 일을하는지 확인합니다. 식별자가 지저분하다. – BrainOverfl0w

관련 문제