Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with UISearchController [Xcode 6 beta 5] #33

Open
fatuhoku opened this issue Aug 9, 2014 · 1 comment
Open

Compatibility with UISearchController [Xcode 6 beta 5] #33

fatuhoku opened this issue Aug 9, 2014 · 1 comment

Comments

@fatuhoku
Copy link

fatuhoku commented Aug 9, 2014

In iOS 8, UISearchDisplayController has been deprecated in favour of using UISearchController instead.

The interface of UISearchController works quite differently: it takes a result view, as well as a so called id <UISearchResultsUpdating> delegate to let the user have a chance of updating the UI.

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController;

I thought TLTableViewController's automatic table updates would provide a perfect drop-in implementation of this method. All one needs to do is update the data model:

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController {
    NSString *searchText = searchController.searchBar.text;

    // ... Create a new array-based data model based on the search text.
    TLIndexPathDataModel *dataModel = f(searchText);
    self.indexPathController.dataModel = dataModel;  // implicitly calls `performUpdates... on table view`
}

However, surprisingly, this does not actually work. The UI of the table view doesn't get updated with the latest rows.

I'm using ignoreDataModelUpdates = YES and an explicit [tableView reloadData] to workaround this for the time being.

@wtmoose
Copy link
Member

wtmoose commented Aug 9, 2014

If you provide a sample project, I'll take a look.

Tim

Sent from my phone.

On Aug 9, 2014, at 3:57 AM, Hok Shun Poon notifications@github.com wrote:

In iOS 8, UISearchDisplayController has been deprecated in favour of using UISearchController instead.

The interface of UISearchController works quite differently: it takes a result view, as well as a so called id delegate to let the user have a chance of updating the UI.

  • (void)updateSearchResultsForSearchController:(UISearchController *)searchController;
    I thought TLTableViewController would be a perfect drop-in implementation of this method:

(void)updateSearchResultsForSearchController:(UISearchController *)searchController {
NSString *searchText = searchController.searchBar.text;

// ... Create a new array-based data model based on the search text.
TLIndexPathDataModel *dataModel = f(searchText);
self.indexPathController.dataModel = dataModel; // implicitly calls performUpdates... on table view
}

However, surprisingly, this does not actually work. The UI of the table view doesn't get updated with the latest rows.

I'm using ignoreDataModelUpdates = YES and an explicit [tableView reloadData] to workaround this for the time being.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants