2014-09-24 3 views
1

Я новичок в iOS, и у меня возникли проблемы с отображением контроллера навигации в моем taBbar после обновления Xcode 6.Сочетание TabBar и навигационного контроллера IOS8

С Xcode 5, это было прекрасно, но сейчас работает на тренажере я получаю сообщение об ошибке «Нагрузочного приложение из-за неперехваченное исключение„NSInvalidArgumentException“, причиной:„Раздвигая навигационный контроллер не поддерживается“» и приложение сбои. Вот мой код:

**appDelegate.m** 

- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:  
(NSDictionary *)launchOptions{ 

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
self.window.backgroundColor =[UIColor whiteColor]; 
[self.window makeKeyAndVisible]; 

*// tabBar items* 

ItemUnViewController *itemUnViewController = [[ItemUnViewController alloc] 
                  initWithNibName:nil 
                  bundle:NULL]; 


ItemDeuxViewController *itemDeuxViewController = [[ItemDeuxViewController alloc] 
                   initWithNibName:nil 
                   bundle:NULL]; 

*//tabBar* 

UITabBarController *tabBarController = [[UITabBarController alloc] init]; 

[tabBarController setViewControllers:@[itemUnViewController,itemDeuxViewController]]; 


*//setting tabBar as rootView* 

self.window.rootViewController = tabBarController; 


*// navigation Controllers* 

UINavigationController *itemUnNavigationController = 
[[UINavigationController alloc] 
initWithRootViewController:itemUnViewController]; 

UINavigationController *itemDeuxNavigationController = 
[[UINavigationController alloc] 
initWithRootViewController:itemDeuxViewController]; 


*//Combining tabBar and Navigation Controllers* 

[tabBarController setViewControllers:@   
[itemUnNavigationController,itemDeuxNavigationController]]; 

return YES; 
} 

Я даже попробовал этот способ http://blog.rifkilabs.net/exploring-navigation-controller-and-tab-bar-controller.html но я получаю то же сообщение об ошибке.

Благодарим за помощь.

ответ

0
  tabBar_Controller = [[UITabBarController alloc]init]; 
       [tabBar_Controller setDelegate:self]; 



      ViewController1 *obj_1 = [obj_story instantiateViewControllerWithIdentifier:@"VC1"]; 
      UINavigationController *navi_vc1 = [[UINavigationController alloc]initWithRootViewController:obj_1]; 
      navi_vc1.navigationBarHidden = YES; 

     ViewController2 *obj_2 = [obj_story instantiateViewControllerWithIdentifier:@"VC2"]; 
      UINavigationController *navi_vc2 = [[UINavigationController alloc]initWithRootViewController:obj_2]; 
      navi_vc2.navigationBarHidden = YES; 


     [tabBar_Controller setViewControllers:[NSArray arrayWithObjects:navi_vc1,navi_vc2,nil]]; 

    //Hide Tabbar View Controller.// 
     [self hideTabBar] 
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    -(void) hideTabBar 
    { 
     for(UIView *view in tabBar_Controller.view.subviews) 
     { 
      if([view isKindOfClass:[UITabBar class]]) 
      { 
       [view setFrame:CGRectMake(view.frame.origin.x, [UIScreen mainScreen].bounds.size.height, view.frame.size.width, view.frame.size.height)]; 
      } 
      else 
      { 
       [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, [UIScreen mainScreen].bounds.size.height)]; 
      } 
     } 
    } 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
-(void)create_BottomBarButton 
{ 
    UIView *viewBottom = (UIView *)[self.window viewWithTag:Tag_BottomView]; 

    if (viewBottom == nil) 
    { 
     @try 
     { 
      viewBottom = [[UIView alloc]init]; 
      [viewBottom setFrame:CGRectMake([UIScreen mainScreen].bounds.origin.x, [UIScreen mainScreen].bounds.size.height-(HeightOfBottomBar+KsubviewHeight), [UIScreen mainScreen].bounds.size.width, HeightOfBottomBar)]; 
      [viewBottom setBackgroundColor:RGB(47.0, 45.0, 45.0, 1.0)]; 
      [viewBottom setTag:Tag_BottomView]; 
      NSArray *arrImage = [NSLocalizedString(@"arrBottomBarImgs", nil)componentsSeparatedByString:@","]; 
      float x = 0.0; 
      for (int i =0; i < kTotalTab; i++) { 
       [self create_TabBtn:viewBottom frame:CGRectMake(x, 0, 62,62) withTag:i+1 withImage:[arrImage objectAtIndex:i]]; 
       x += 64.5; 
      } 
      [self.window addSubview:viewBottom]; 
     } 
     @catch (NSException *exception) 
     { 
      NSLog(@"EXCEPTON %@",[exception description]); 
     } 
    } 
} 
-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=- 
-(void)select_Tab:(UIButton *)btn 
{ 
    @try { 
     [[tabBar_Controller.viewControllers objectAtIndex:btn.tag-1] popToRootViewControllerAnimated:YES]; 
     [tabBar_Controller setSelectedIndex:btn.tag-1]; 
    } 
    @catch (NSException *exception) { 
     NSLog(@"%s",__PRETTY_FUNCTION__); 
    } 
} 

- = - = - = - = - = - = - = - = - = - = - = - = - = -

-(void)pushTabBarIntoNavigationBar 
{ 
    [navi setNavigationBarHidden:YES]; 
    [[UIApplication sharedApplication] setStatusBarHidden:NO]; 
    [navi pushViewController:tabBar_Controller animated:YES]; 
} 

- = - = - = - = - = - = - = - = - = - = - =

navi = [[UINavigationController alloc]initWithRootViewController:tabBar_Controller]; 
[navi setNavigationBarHidden:YES]; 
    self.window.rootViewController = navi;