Moving a UISearchBar Position in the Navigation Bar

I don’t know why this is happening, I have a UISearchBar in my navigation bar, however, when I start scrolling through the SearchResultsTableView, it looks like the search bar is skipping in its position and I get an error warning: [<CALayer: 0x16550840> display]: Ignoring bogus layer size

Here are screenshots of position changes in SearchBar.

enter image description hereenter image description here

It is quite minimal, but very noticeable. Any ideas? Thanks!

Here is the code that I use to customize my search bar

if (!self.cardSearchDisplayController) {
    CGFloat searchBarHeight = 64.0;
    self.cardSearchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, searchBarHeight)];
    self.cardSearchBar.delegate = self;
    self.cardSearchBar.showsCancelButton = YES;

    self.cardSearchDisplayController = [[UISearchDisplayController alloc]initWithSearchBar:self.cardSearchBar contentsController:self];
    self.cardSearchDisplayController.delegate = self;
    self.cardSearchDisplayController.searchResultsDataSource = self;
    self.cardSearchDisplayController.searchResultsDelegate = self;
    self.navigationItem.titleView = self.cardSearchDisplayController.searchBar;
    self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
}
+4
source share
1 answer

For ios 7 you should use this, in viewDidLoad this is fixed for me:

self.edgesForExtendedLayout = UIRectEdgeNone;

May this help you.

+1

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


All Articles