TableView (search results table) unexpectedly sees

I am working on an application that implements a search display controller. In the presentation of the table of search results, the behavior is not always correct, and I am trying to solve this problem from a few days. Here is a screen recording of the behavior.

scroll Issue in search results table view

I do not change the frame or presentation frame of the table. I only fire the first responder when there is no text in the search field and the method is called [searchDisplayController setActive: animated: ].

Please help me.

+4
source share
6 answers

, scrollIndicatorInsets contentInsets searchResultsTableView, , 'willShowSearchResultsTableView:', :

- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView
{
   [tableView setContentInset:UIEdgeInsetsZero];
   [tableView setScrollIndicatorInsets:UIEdgeInsetsZero];
}
+9

, TableView SearchResultsDisplayController. (textDidChange).

, SearchResultsTableView.

+1

, , (iPhone iPad), ( iOS 8, Xcode 6.0.1, Swift).

- contentInset.bottom scrollIndicatorInsets.bottom searchResultsTableView . , , , . , , . , - , , .

, , :

searchController.searchResultsTableView.contentInset.bottom = 0
searchController.searchResultsTableView.scrollIndicatorInsets.bottom = 0

, . , .

+1

@ricardoaraujo, , , ( 200 , 1 x keyboard.height).

searchResultsTableView ( , ), contentInset UIEdgeInsetsZero.

, , UITableView ( @Vignesh), , .

iOS7, , , iOS8.0.3. .

+1

@Vignesh it’s good that the problem is solved, but UISearchDisplayControllerdoes it for us. It is true that this is a problem with the calculation of the keyboard, so I just had to bring back contentInsetand scrollIndicatorInsetsto UIEdgeInsetsZerowhere is my keyboard.

func searchDisplayController(controller: UISearchDisplayController, didHideSearchResultsTableView tableView: UITableView) {
    NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardDidHideNotification, object: nil)
}

func searchDisplayController(controller: UISearchDisplayController, willShowSearchResultsTableView tableView: UITableView) {
    NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide", name: UIKeyboardDidHideNotification, object: nil)
}

func keyboardWillHide() {
    let tableView = self.searchController.searchResultsTableView
    tableView.contentInset = UIEdgeInsetsZero
    tableView.scrollIndicatorInsets = UIEdgeInsetsZero
}

This is just another workaround, but it still works on iOS7 +

0
source

Quick version:

func searchDisplayController(controller: UISearchDisplayController, willShowSearchResultsTableView table: UITableView!) -> Void {
    table.contentInset = UIEdgeInsetsZero
    table.scrollIndicatorInsets = UIEdgeInsetsZero
}

Based on @ user2795503 answer

0
source

All Articles