Thank you for reading my question. I have an interesting problem that I cannot figure out and hoping the community may be able to help. I have a UITableViewController
(LibraryViewController) that has a UISearchDisplayController
as a variable. I have two other objects. First, a subclass of NSObject
that defines my data object (two NSString
objects), called LibraryDataObject. The second, a subclass of NSObject
that has two NSMutableArray
objects and implements the UITableViewDataSource
protocol called LibraryDataModel.
LibraryViewController also owns an instance of a LibraryDataModel called libraryDataSource. It is initialized properly. Also, the delegates for LibraryViewController and the UISearchDisplayController
are set to LibraryDataModel. The non-searched view populates correctly. And, when I search, the list populates the correct items based on the search terms. The code is based on the TableSearch documentation code.
Here is where my problem becomes evident. When searching, the table is reduced to the terms in the search box. However, when I scroll the table, and move beyond the bounds of the search terms, it starts messaging tableView:cellForRowAtIndexPath:
with the tableview of the base UITableViewController
.
Has anyone ran into this particular condition before? Thank you.
I opened a case with Apple and they helped me out. The behavior isn't what I want, but it explains this problem. I was adding the search bar by pushing it onto the stack with [self.parentViewController.view addSubview:searchBar]; However, I should have added the search bar with self.tableView.tableHeaderView = searchBar; This problem went away, however the search bar is at the top of the tableview, and not static on the view. Seeing if that can be modified.