2012-06-05 4 views
0

Xcode 4.3에 탭 표시 줄 응용 프로그램이 있는데 탭바가 표시되기 전에 로그인 화면을 삽입하려고합니다. presentModalViewControlleranimated:YES이있는 경우 앱이 정상적으로 작동하지만 애니메이션이없는 경우보기가 표시되지 않습니다.탭 응용 프로그램이 표시되지 않습니다.

@synthesize window = _window; 

@synthesize tabBarController = _tabBarController; 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // Override point for customization after application launch. 
    UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; 
    UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 

    self.tabBarController = [[UITabBarController alloc] init]; 
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil]; 
    self.window.rootViewController = self.tabBarController; 

    LogInViewController *logViewController = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil]; 
    [self.window addSubview:_tabBarController.view]; 

    [self.tabBarController presentModalViewController:logViewController animated:YES]; 
    //This wont work 
    //[self.tabBarController presentModalViewController:logViewController animated:NO]; 

    [self.window makeKeyAndVisible]; 
    return YES; 

} 

-(void)loginDone{ 

    NSLog(@"back to the app delegate"); 
    [self.tabBarController dismissModalViewControllerAnimated:YES]; 


} 
  1. 이 할 수있는 올바른 방법인가?
  2. 코드가 animated:NO과 작동하지 않는 이유는 무엇입니까?
  3. 출력이 Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x689d350> 인 경우에도이 정보를 얻을 수 있습니다.

답변

1

우선보기 컨트롤러 설정 전에 [self.window makeKeyAndVisible];을 이동하십시오.

또한 모달보기 컨트롤러는뷰 컨트롤러의 메서드 내에서 표시되어야하며,이 뷰 컨트롤러는 먼저 로그인 화면을 표시하기 전에 응용 프로그램 뷰 계층 구조가 완전히 초기화되었는지 확인해야합니다.

1

이 작업을 수행하지 마십시오

[self.window addSubview:_tabBarController.view]; 

이를 수행

self.window.rootViewController = _tabBarController; 

이 화면에 tabBarController을 넣어 것입니다. 하지만 그건 정확히 당신이 원하는 게 아니에요 ... 내 충고는 :

1) logViewController을 넣어 시작하면이 위와 같이 보여집니다.

2) 원하는 정보 (로그인에 성공)를 얻었 으면 AppDelegate에게 rootViewController을 전환하도록 알려주세요. 이것은 위임 또는 통지로 수행 할 수 있습니다.

또한 Toastor가 간접적으로 지적한 것처럼 UIViewController에서 실제로 (AppDelegate가 아닌) presentViewController를 시작해야합니다.

관련 문제