开发者

How can I add a UISearchDisplayController to a UIView?

开发者 https://www.devze.com 2023-01-16 16:22 出处:网络
How can I add a UISearchDisplayController to a UIView? I开发者_高级运维nterface builder won\'t let me.A UISearchDisplayController cannot be added to a UIView because it doesn\'t inherit from a UIView.

How can I add a UISearchDisplayController to a UIView? I开发者_高级运维nterface builder won't let me.


A UISearchDisplayController cannot be added to a UIView because it doesn't inherit from a UIView. You can add a UISearchBar in Interface builder with an IBOutlet and then create a UISearchDisplayController with that UISearchBar programmatically.


Just do it in code e.g. (assuming the view controller is vc):

[vc addSubview:mySearchDisplayController.searchBar];
// Note that searchBar is the view, and mySearchDisplayController only CONTROLS the searchBar etc.
0

精彩评论

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