开发者

How can I create a Spotlight-like search bar in an iPhone app?

How can I create a Spotlight-like search bar in an iP开发者_JS百科hone application?


Just drag and drop a UISearchBar in Interface Builder and link it up as normal... Then you need some code to search your tableview/data. There are numerous ways to do that, documented all over the internet. Google is your friend.


Drag a UISearchBar into IB and connect it to your view controller. It needs a delegate to function so, you could make your view controller conform to the UISearchBarDelegate protocol or you could do the searching in your data layer. But the best way is to use a UISearchDisplayController. Any way the delegate needs access to the data being searched so that it can use a predicate to filter the data. Here's one of Apple's examples of how to do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜