在自定义 segue 转换期间,视图的导航栏项目错位 [英] During custom segue transition, view's navigation bar items are misplaced

查看:57
本文介绍了在自定义 segue 转换期间,视图的导航栏项目错位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义转场,它使用 UIViewAnimationOptionTransitionFlipFromLeft 在视图之间转换.

I've got a custom segue that uses the UIViewAnimationOptionTransitionFlipFromLeft to transition between views.

当新视图出现在屏幕上时,导航栏元素从左对齐状态跳到其适当位置会引起短暂但可辨别的闪烁".以下是在过渡即将结束时捕获的屏幕截图:

When the new view comes on screen, there is a brief but discernible 'blink' caused by the Navigation Bar elements jumping from a left-aligned state to their appropriate positions. Following is a screenshot captured near the very end of the transition:


可以看到标题和两个栏按钮项是左对齐的;完全不适合他们最终休息的地方.


You can see that the title and two bar button items are left aligned; completely out of place from where they will eventually rest.

以下是转换完成后的截图:

Following is a screenshot captured after the transition has completed:


此处按钮和标题的位置正确.在第一张和第二张图像之间的瞬间,图标会闪烁到位.


Here the buttons and title are positioned correctly. During the instant between the first and second images, the icons blink into position.

视图在故事板中设置.该视图不是 UINavigationController 层次结构的一部分,因此导航栏及其项目是通过属性检查器在视图上手动创建的,模拟指标"->顶部栏:半透明导航栏".

The view is setup in storyboard. The view is not part of a UINavigationController hierarchy, so the navigation bar and its items are manually created on the view via the attributes inspector, 'Simulated Metrics' -> 'Top Bar: Translucent Navigation Bar'.

如何强制导航栏项目在过渡期间首次出现时正确定位?

How can I force the navigation bar items to be correctly positioned when they first appear during the transition?

先谢谢你!:)

推荐答案

明白了!我发现在 transitionWithView 中使用 [UIView performWithoutAnimation:^{}] 块解决了这个问题:

Got it! I found that using the [UIView performWithoutAnimation:^{}] block inside of transitionWithView solved this problem:

[UIView transitionWithView:src.navigationController.view duration:0.2
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{
                                [UIView performWithoutAnimation:^{
                                    [navController setViewControllers:[NSArray arrayWithObject:dst] animated:NO];
                                }];
                            }
                completion:nil];

这篇关于在自定义 segue 转换期间,视图的导航栏项目错位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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