2013-04-05 81 views
0

我有一個UItabbarController與兩個視圖控制器。當我點擊一個視圖控制器中的登錄按鈕時,它應該帶我到其他tabbarController。當發生這種情況時,我得到當前tabbarcontroller頂部的第一個視圖控制器,它看起來像另一個。它可以在iPhone 6.0模擬器中正常工作,但在iPhone 5.0模擬器中描述失敗。一個視圖控制器出現在另一個視圖控制器在iOS 5和以下版本

在appDelegate.m:

 - (void)sessionStateChanged:(FBSession *)session 
        state:(FBSessionState) state 
        error:(NSError *)error 
    { 
    switch (state) { 
    case FBSessionStateOpen: 
     if (!error) { 




      if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone) 
      { 
       FLogin *flogin=[[FLogin alloc]initWithNibName:@"FLogin" bundle:nil]; 

       self.window.rootViewController=fblogin; // I think because of this I m getting this issue 


      } 



     } 

} 

在flogin.m

tab=[[[UITabBarController alloc]init]autorelease]; 
      ViewController *searchViewController=[[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil]autorelease]; 
      Account *account=[[[Account alloc]initWithNibName:@"Account" bundle:nil]autorelease]; 
      [email protected]"My Account"; 



      tab.viewControllers=[NSArray arrayWithObjects:searchViewController,account,nil]; 
      for(UIViewController *tab1 in tab.viewControllers) 

      { 
       if ([[[UIDevice currentDevice] systemVersion] floatValue]>5.0 ||[[[UIDevice currentDevice] systemVersion] floatValue]==5.0) 
       { 
        [tab.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
                  [UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:16.0], UITextAttributeFont, nil] 
                forState:UIControlStateNormal]; 
       } 
      } 

      [self presentModalViewController:tab animated:NO]; 
+0

你改變你的根視圖控制器響應登錄? – 2013-04-05 13:35:14

+0

iam僅在iOS 5.1,iOS 5 iOS 4.3和iOS 6中出現此問題沒有問題 – siva 2013-04-05 13:41:28

+0

可能是我的應用程序中僅包含在iOS 6中的任何功能 – siva 2013-04-05 13:42:18

回答

0

你說你只是想響應登錄程序切換標籤?如果是這樣,你不應該使用presentModalViewController:。切換標籤的正確方法是使用UITabBarController方法。

[self.tabBarController setSelectedIndex:1]; 

[self.tabBarController setSelectedViewController:self.myOtherViewController]; 
+0

IAM不不切換標籤IAM創建從根視圖控制器 – siva 2013-04-05 16:14:42

+0

另一種看法,但它在iOS 6中 – siva 2013-04-05 16:17:12

+0

工作你是否理解我的問題 – siva 2013-04-05 18:06:26

相關問題