简体   繁体   English

清除搜索栏导航栏的过渡

[英]Clean transition for a searchbar navigationBar

I have a navigationbar where I have the searchbar as the title view. 我有一个导航栏,其中有搜索栏作为标题视图。 The problem arises when I want to transition to the next viewController. 当我想过渡到下一个viewController时,就会出现问题。

As you can see, the transtion is done in such a way that the navigationBar is not change at all, but only the viewController is slide in.. as shown in the pics below. 如您所见,转换的方式是根本不更改navigationBar,而是仅将viewController滑入..如下图所示。

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

This transition introduces some unexpected result.. for example, the back-arrow becomes coated in a white layer which the original image does not have. 这种过渡会带来一些意想不到的结果,例如,后箭头被涂上了原始图像所没有的白色层。

After wards, I check out other apps.. I realise that the transition in other apps for a navigationbar that contains a searchbar is done difference... 在病房之后,我签出了其他应用程序。.我意识到,在其他应用程序中,包含搜索栏的导航栏的转换是完全不同的...

For example, in facebook, the entire viewController including the navigationbar is replaced, as shown below. 例如,在facebook中,包括导航栏的整个viewController被替换,如下所示。

在此处输入图片说明

在此处输入图片说明

the transition is too fast for me to capure, but you can try to do the search in the facebook and see taht the entire viewcontroller including the navigationbar is swiped out. 过渡对于我来说太快了,但是您可以尝试在Facebook中进行搜索,然后看到包括导航栏在内的整个ViewController都被刷掉了。

Anyone knows how to achieve something like this? 有谁知道如何实现这样的目标?

Thanks! 谢谢!

In the viewController that has the search bar, use the following deinit method 在具有搜索栏的viewController中,使用以下deinit方法

deinit {
    if #available(iOS 9.0, *) {
        searchController.loadViewIfNeeded()
    } else {
        let _ = searchController.view
    }
}

I think your problem is a presentation context! 我认为您的问题在于演示环境! Try something like this: 尝试这样的事情:

self.definePresentationContext = true

Put this line of code to the SearchBarOwnerViewController's viewDidLoad . 将这行代码放入SearchBarOwnerViewController的viewDidLoad

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM