【问题标题】:one view controller appears on another view controller in iOS 5 and below versions在 iOS 5 及以下版本中,一个视图控制器出现在另一个视图控制器上
【发布时间】:2013-04-05 13:31:52
【问题描述】:

我有一个带有两个视图控制器的 UItabbarController。当我单击一个视图控制器中存在的登录按钮时,它应该将我带到另一个 tabbarController。发生这种情况时,我会在当前 tabbarcontroller 的顶部获得第一个视图控制器,它看起来像另一个视图控制器。它在 iPhone 6.0 模拟器中运行良好,但如 iPhone 5.0 模拟器中所述失败。

在 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];
            account.title=@"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];

【问题讨论】:

  • 您是否正在更改您的根视图控制器以响应登录?
  • 我只在 iOS 5.1、iOS 5、iOS 4.3 和 iOS 6 中遇到这个问题
  • 可能是我的应用程序中是否有任何仅包含在 iOS 6 中的功能
  • 我在该视图中有一个登录视图我有一个 Facebook 登录选项如果点击这个我的应用程序主屏幕应该出现但我的问题是我的主屏幕出现在登录视图中跨度>
  • @siva,我们需要更多地了解该问题以更好地帮助您。编辑您的原始帖子并提供:1)有关“所描述的失败”的含义的更详细信息。有错误信息吗?如果是这样,请发布它。应用程序会崩溃吗?如果有,在哪一行。等等... 2) 来自 AppDelegate 的 .h 和 .m 文件的完整代码(或者您正在执行导致错误的逻辑的任何位置)。

标签: iphone ipad xcode4.5


【解决方案1】:

您是说您只是想以编程方式切换选项卡以响应登录?如果是这样,您不应该使用presentModalViewController:。切换标签的正确方法是使用 UITabBarController 方法。

[self.tabBarController setSelectedIndex:1];

[self.tabBarController setSelectedViewController:self.myOtherViewController];

【讨论】:

  • 我没有切换标签我从根视图控制器创建另一个视图
  • 你明白我的问题吗
  • @siva,您需要将所有代码发布到您的应用委托标头 (.h) 和实现 (.m) 文件中。否则很难说到底是什么问题。您还需要发布您在 Xcode 中看到的任何错误消息。说您的应用程序只是“按描述失败”并不是很有帮助。帮助我们理解这意味着什么。
  • 我发布了我的应用委托文件
  • @Aaron 你明白我真正的问题是什么
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-18
  • 2013-03-29
  • 1970-01-01
相关资源
最近更新 更多