question

AlokKumarPandey-8826 avatar image
0 Votes"
AlokKumarPandey-8826 asked RobCaplan edited

Search Bar is misplaced (vertically down) when search is performed and device rotated from Portrait to Landscape and other way round.

Hi,
We are facing a issue with search bar which is placed in the UITableViewController's TableView header. Please refer the attached screenshot for more details.

The below code for creating the searchBar :-

    // UISearchController is created

        this.searchController = new UISearchController(this.resultsController)
         {
             WeakDelegate = this,
             WeakSearchResultsUpdater = this
         };

         this.searchController.SearchBar.SizeToFit();
         this.searchController.SearchBar.BarTintColor = UIResources.SearchBarBackgroundColor;
         this.searchController.SearchBar.BackgroundColor = UIResources.SearchBarBackgroundColor;
         this.searchController.SearchBar.WeakDelegate = this;
         this.searchController.SearchBar.Placeholder = this.LocalizationService.Localize(LocalizationKeys.SearchBarHint);
         this.searchController.HidesNavigationBarDuringPresentation = false;
         this.searchController.SearchResultsController.EdgesForExtendedLayout = UIRectEdge.None;
         this.searchController.SearchResultsController.AutomaticallyAdjustsScrollViewInsets = true;

        // Added to UITableViewController's UITableView header view

            this.reportListController.TableView.TableHeaderView = this.searchController.SearchBar;





Thanks & Regards,
Alok Pandey

dotnet-xamarin
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I created a simple demo to test but did not replicate the issue .

Would you mind sharing us a basic, reproducible project to test ?

You can upload it via github and attach the repo link here .

0 Votes 0 ·

It's difficult to extract the code from the project. I have also tried to create the sample and it's working.

One thing I have noticed:-

Search bar is added to header


this.reportListController.TableView.TableHeaderView = this.searchController.SearchBar;

Is this correct as per SearchController doc, The iOS 11 and later we should add searchController to navigationItem.searchController.

I have tried to repeat the same steps but search controller was not visible in the NavigationBar

Am suggetsion?


0 Votes 0 ·

0 Answers