导航栏从状态栏下跳出来?

时间:2013-11-19 20:12:58

标签: ios uiviewcontroller ios7

我的主视图控制器中有一个按钮,它使用segue推动带有嵌入式视图控制器的导航控制器。

当显示新的视图控制器时,其上的导航栏会短暂显示在状态栏下。 (状态栏未隐藏。)内容(相对于顶部布局指南)位于正确的位置。一旦动画完成,它就会自行修复。

当视图再次被关闭时,会发生同样的事情:主视图控制器会短暂覆盖状态栏。对于主视图控制器,这是一个更重要的,因为它基于UITableViewController;整个桌子跳了起来。同样,当动画完成时,视图控制器会自行修复。

我尝试在导航栏上关闭半透明效果,但这只会使问题更加明显。所有这些都在iOS 6上按预期工作。

我在这里上传了一个简约的测试用例:https://github.com/tewha/FlipTest

4 个答案:

答案 0 :(得分:3)

另一个简单的诀窍是:

MasterViewController

什么时候准备Segue:

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    [UIView transitionWithView:self.navigationController.view
                      duration:0.75
                       options:UIViewAnimationOptionTransitionFlipFromRight
                    animations:nil
                    completion:nil];
}

在展开 AboutViewController

- (IBAction)aboutUnwind:(UIStoryboardSegue *)segue {

[UIView transitionWithView:((UIViewController *)segue.sourceViewController).view
                  duration:0.75
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:nil
                completion:nil];

}

答案 1 :(得分:1)

这是iOS7布局系统中的一个错误。我发现通过状态栏高度降低导航控制器视图的高度(不是被推动的视图控制器!)并将其置于y =状态栏高度将有很大帮助,但状态栏仍然会有一个小的闪烁与导航控制器“合并”。

作为一方,请查看iOS7.1b1中是否仍然存在该错误。

答案 2 :(得分:0)

ios 7中存在一个问题,带有导航栏,导航栏出现在视图上方或显示导航栏和视图之间的间隙,您可以借助以下代码解决此问题

iOS 7中引入了一个新属性,可让您像以前版本的iOS一样调整布局行为。您的视图控制器中的此代码,您应该是好的导航栏占用的空间应该自动计算

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;

iOS 7 navigation bar jumping / stretching upon viewDidAppear

获得的答案

答案 3 :(得分:0)

这是英国工具包中的错误。避免使用标准方法

' performSegueWithIdentifier'或者' presentViewController'

在这里,我从一个控制器转换到另一个控制器,然后使用UIView过渡动画在委托回调中转换回来。

-(void)photoButtonPressed:(NSNotification*)notification
{        
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Media"
                                                         bundle:nil];

    UINavigationController *navCon = [storyboard instantiateInitialViewController];

    PhotoCaptureViewController *controller = navCon.viewControllers.firstObject;
    controller.delegate = self;

    CustomTabBarViewController *tabBarController = (CustomTabBarViewController*)self.tabBarController;

    [UIView transitionWithView:self.navigationController.view duration:0.75 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
                        [tabBarController.parentViewController addChildViewController:navCon];
                        [tabBarController.parentViewController.view addSubview:navCon.view];
                    } completion:^(BOOL finished) {
                        [navCon didMoveToParentViewController:tabBarController.parentViewController];
                    }];
}

-(void)photoCaptureViewController:(PhotoCaptureViewController *)controller dismissButtonPressed:(UIButton *)dismissButton
{
    CustomTabBarViewController *tabBarController = (CustomTabBarViewController*)self.tabBarController;

    [UIView transitionFromView:controller.navigationController.view toView:tabBarController.view duration:1 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
        [controller.navigationController willMoveToParentViewController:nil];
        [controller.navigationController removeFromParentViewController];
        [controller.navigationController.view removeFromSuperview];
    }];

}

这是关于容器视图Khanlou's blog post

的精彩读物