【问题标题】:Tab bar moves away from screen标签栏远离屏幕
【发布时间】:2014-06-25 18:34:34
【问题描述】:

当我点击 Test2 View Controller 中的 按钮 时,我的标签栏应该停留在屏幕上。

我已将 Test 3 View Controller 的底栏设置为 推断,并尝试了 半透明标签栏。我已将转场从 push 更改为 modal。我试过this solution,但不适用于iOS7。

TestTabBarController.m 这也不起作用:

- (void)viewDidLoad
{
    Test3ViewController * viewController1 = [[Test3ViewController alloc] initWithNibName:nil bundle:nil];
    UINavigationController *homeNavi=[[UINavigationController alloc]initWithRootViewController:viewController1];
    self.viewControllers = [NSArray arrayWithObjects:homeNavi, nil];    
}

这也行不通:

- (IBAction)buttonpress:(id)sender {      
   UIStoryboard *storyboard = [UIStoryboard   storyboardWithName:@"Main" bundle:nil];       
   Test3ViewController * test3ViewController = (Test3ViewController *)[storyboard instantiateViewControllerWithIdentifier:@"test3View"];     
   [self.navigationController pushViewController:test3ViewController animated:YES]; 
}

【问题讨论】:

    标签: objective-c xcode ios7 uitabbarcontroller


    【解决方案1】:

    首先: 您在storyboard 中的Test2 到Test3 的链接是Modal, 将其更改为Push:

    你会看到你的导航栏。

    第二: 不要为您的任务使用segue 机制。 在UINavigationController上使用pushViewController

    【讨论】:

    • 这不起作用:- (IBAction)buttonpress:(id)sender { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; Test3ViewController * test3ViewController = (Test3ViewController *)[storyboard instantiateViewControllerWithIdentifier:@"test3View"]; [self.navigationController pushViewController:test3ViewController animated:YES]; }
    【解决方案2】:

    模态视图将覆盖标签栏。如果您想在点击“按钮”后加载视图,请执行以下操作:

    - (IBAction) loadNewView:(id) sender {
        Test3ViewController * viewController1 = [[Test3ViewController alloc] initWithNibName:nil bundle:nil];
        [[self navigationController] pushViewController:viewController1 animated:YES];
    }
    

    然后将其与您的按钮链接...

    【讨论】:

    • 这不起作用:不支持推送导航控制器。
    【解决方案3】:

    答案是:在 Test Tab Bar Controller 和 Test2 View Controller 之间添加一个 Navigation 控制器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-09
      • 1970-01-01
      • 1970-01-01
      • 2012-12-04
      相关资源
      最近更新 更多