IOS 11 UISearchController in navigation bar with UIRefreshControl causes circuit failure

I am trying to use UIRefreshControl in a table view along with the new searchController API on navigationItem .
Now that I have installed hidesSearchBarWhenScrolling , the pull down to refresh animation no longer appears, and the update control just appears at a specific point.

enter image description here

It seems like a bug in UIKit (... the same procedure as every year). Has anyone found a solution for this?

To reproduce the problem, add it to the new "master / detail" iOS 11 sample project:

 - (void)viewDidLoad { // [setup code here] self.refreshControl = [UIRefreshControl new]; self.navigationItem.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; self.navigationItem.hidesSearchBarWhenScrolling = NO; // <-- setting this causes jumpy UI } 
+5
source share
1 answer

I just experienced the same problem. This definitely looks like a bug in UIKit. It would definitely be something a radar feed would be worthy.

I found a very hacky way to mitigate it, though:

 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { //Fixes a bug in UIKit where the refresh control is broken when `hidesSearchBarWhenScrolling` is NO. if (@available(iOS 11.0, *)) { self.navigationItem.hidesSearchBarWhenScrolling = scrollView.contentOffset.y < -scrollView.adjustedContentInset.top; } } 

Basically, what happens is that whenever the scrolling is viewed from above (where the update control becomes visible), this bit of code will turn hidesSearchBarWhenScrolling back into YES . When the user scrolls back the page again, it will be set to NO , and the search bar will remain visible.

I hope Apple fixes this in a future version of iOS, but for the current delivery versions this will probably have to be done.

0
source

Source: https://habr.com/ru/post/1273269/


All Articles