带有加载指示器的UISearchController

问题描述:

我实现了UISearchController,并且从js回调中获取数据,但是当我在searchbar中进行录音时,需要花费一些时间来放置数据,所以我想知道如何实现将indicator加载到UISearchController

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

那时您开始搜索时,可以创建活动指标,并使用addSubView方法将其添加为UISearchBarsubview. >

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];

完成搜索后,请使用removeFromSuperView方法将其从搜索栏中删除.

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