UINavigationBar在transitionFromViewController期间跳转20像素 [英] UINavigationBar jumps 20pixels during transitionFromViewController

查看:117
本文介绍了UINavigationBar在transitionFromViewController期间跳转20像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用Apple的UIViewController包含时,我遇到了动画两个UIViewControllers之间转换的问题。

In trying to attempt to use Apple's UIViewController containment I have encountered a problem with animating the transition between two UIViewControllers.

这是设置...我有创建了一个UITabBarController,在其中一个选项卡中我创建了一个UIViewController作为容器。这个ViewController管理UIViewController和UINavigationController之间的转换。之前的观点是:

Here is the set up... I have created a UITabBarController and within one of the tabs I have created a UIViewController as a container. This ViewController manages the transition between a UIViewController and a UINavigationController. The before view is:

点击下一步按钮后,视图将以flipFromRight过渡开始转换。在过渡期间,导航栏处于到视图中,但位于距视图顶边20个像素的位置。如下图所示:

When the Next button is tapped the view begins it's transition with a flipFromRight transition. During the transition, the Navigation bar is in "to" view but is located 20pixels down from the top edge of the view. Picture below:

绿色是容器视图的背景颜色。新视图完成转换后,导航栏会快速移动到视图顶部,最终结果为:

The green is the background color of the container view. Once the new view completes the transition, the Navigation bar snaps up to the top of the view and the final result is:

捕捉到位的时间与动画的持续时间无关。我实现了我想要的最终状态,但过渡是一个问题。

The time to snap in place is independent of the duration of the animation. I achieve the final state that I want, but the transition is a problem.

我已经检测了viewController生命周期,导航栏和UITableView的框架是指定的在XIB中。 xib看起来像这样:

I have instrumented the viewController lifecycle and the frames of the Navigation bar and the UITableView are as specified in the XIB. The xib looks like this:

以下是代码:

在-viewDidLoad -

In -viewDidLoad -

_fromVC = [[FromVC alloc] initWithNibName:@"FromVC" bundle:nil delegate:self];

[self addChildViewController:_fromVC];
[self.view addSubview:_fromVC.view];
[_fromVC didMoveToParentViewController:self];

在我的按钮处理程序中 -

In my button handler -

- (void)buttonSelected

{

//
//  Create the "to" View controller
//
ToVC *toVC = [[ToVC alloc] initWithNibName:@"ToVC" bundle:nil];

//
//  Create the navigation controller for the study activity
//
_toNavCon = [[UINavigationController alloc] initWithRootViewController:toVC];

[self addChildViewController:_toNavCon];
[_fromVC willMoveToParentViewController:nil];

[self transitionFromViewController:_fromVC
                  toViewController:_toNavCon
                          duration:0.7
                           options:UIViewAnimationOptionTransitionFlipFromRight
                        animations:nil
                        completion:^(BOOL finished) {
                            [_fromVC removeFromParentViewController];
                            [_toNavCon didMoveToParentViewController:self];
                        }];

}

没有代码to查看更改视图控制器外观的控制器。

There is no code in "to" view controller that changes the appearance of the view controller.

另一部分信息......当我在模拟器中切换In-Call状态栏时导航栏顶部的间隙是In-Call状态栏的高度。

Another bit of information... When I "toggle In-Call status bar" in the simulator the gap at the top of the navigation bar is the height of the In-Call status bar.

我查看了网络上的所有内容,没有任何帮助。有没有人看过这个并且有人修理过它?

I have looked at everything on the web and there is nothing that helps. Has anyone seen this and has anyone fixed it?

推荐答案

我确实找到了答案!!子类UINavigationController和覆盖

I did find an answer!! Subclass UINavigationController and override

- (BOOL)wantsFullScreenLayout{

  return NO;

}

显然,UINavigationController和UITabController总是想要全屏(默认)是) - 调整状态栏 - 您不能以任何其他方式设置此属性。它一直在为我工作。

Apparently, UINavigationController and UITabController always want the full screen (default YES) - adjusting for the status bar - and you can not set this property any other way. It has been working for me.

这篇关于UINavigationBar在transitionFromViewController期间跳转20像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆