chogath chogath - 6 months ago 43
iOS Question

UISearchController with loading indicator

I implemented

UISearchController
and I'm getting the data from a js callback but when I tape in the
searchbar
it takes some time to put the data so I wanted to know how to implement a loading
indicator
into the table view result of
UISearchController

Answer

When you start searching at that time you can create an activity indicator and add it as the subview of UISearchBar using addSubView method.

  UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

//set your frame for activity indicator

[searchBar addSubview: spinner];

[spinner startAnimating];

When you finish the search remove it from the search bar using removeFromSuperView method.