탐색 스택을 사용하여보기를 밀기위한 몇 가지 문제가 있습니다.선택한 탭 막대 항목을 두 번 두드리면 현재보기 컨트롤러가 숨김
I 발생할 문제입니다 뷰 컨트롤러 (FirstViewController라는 이름의 뷰 컨트롤러에서) 탐색 스택에 밀어 너무 좋아하는 탭 표시 줄의 항목을 터치 한 후 : 예상대로 작동
- (void)viewDidLoad
{
[super viewDidLoad];
svc = [[SecondViewController alloc] init];
[self.navigationController pushViewController:svc animated:YES];
}
하지만, 동일한 탭 표시 줄 항목을 다시 만지면 실제 문제가 발생합니다.
현재 뷰 (이전에 푸시 된 SecondViewController)가 제거되면 "완료"버튼을 터치하는 것과 같습니다.
어디서 무슨 일이 일어나고 있는지 추적 할 수 없습니다.
전 진도 덕분에 충분히 명확 해 졌으면 좋겠습니다.
편집 : 루트에 다시 팝업 할 수있는 탐색 컨트롤러의 원인이됩니다 두 번 탭 표시 줄의 항목을 터치
@implementation AppDelegate
@synthesize HomeViewController, FirstViewController, SecondViewController, ThirdViewController, SettingsViewController, tabBarController, window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
FirstViewController *firstViewController = [[FirstViewController alloc]
initWithNibName:nil bundle:nil];
UINavigationController *firstViewControllerNav = [[UINavigationController alloc]
initWithRootViewController:firstViewController];
SecondViewController *secondViewController = [[SecondViewController alloc]
initWithNibName:nil bundle:nil];
UINavigationController *secondViewControllerNav = [[UINavigationController alloc]
initWithRootViewController:secondViewController];
ThirdViewController *thirdViewController = [[ThirdViewController alloc]
initWithNibName:nil bundle:nil];
UINavigationController *thirdViewControllerNav = [[UINavigationController alloc]
initWithRootViewController:thirdViewController];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[firstViewControllerNav,
secondViewControllerNav];
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
[self.window setRootViewController:self.tabBarController];
[self.window makeKeyAndVisible];
return YES;
}
이 TabBarController의있는 viewDidLoad은이를 방지하려면
당신은 내가 이런 식으로 뭔가 트릭을 할 것입니다 믿는 UITabBarControllerDelegate protocol.
의 tabBarController:shouldSelectViewController: 방법을 사용해야합니다? 완료 버튼은 어디에 있습니까? –
tabBarItem의 터치 이벤트에서 코드를 공유하거나 첫 번째 뷰 컨트롤러에 푸시 로직이있을 때 TabBarContoller의 델리게이트를 터치하십시오. –
안녕하세요 Kunal, 이것은 FirstViewController의 viewDidLoad이며 빈 UIView 클래스입니다. (@interface FirstViewController : UIViewController) appDelegate didFinishLaunchingWithOptions에 프로그래밍 방식으로 모든 컨트롤을 추가하고 있기 때문에 touch 이벤트에 코드가 없습니다. –