如何将 UISearchDisplayController 添加到 UIView 中?

发布于 2024-09-19 10:59:19 字数 63 浏览 4 评论 0原文

如何将 UISearchDisplayController 添加到 UIView 中?界面生成器不会让我这样做。

How can I add a UISearchDisplayController to a UIView? Interface builder won't let me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Spring初心 2024-09-26 10:59:19

UISearchDisplayController 无法添加到 UIView,因为它不是从 UIView 继承的。您可以使用 IBOutlet 在界面构建器中添加 UISearchBar,然后以编程方式使用该 UISearchBar 创建 UISearchDisplayController。

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.

失而复得 2024-09-26 10:59:19

只需在代码中执行即可,例如(假设视图控制器是 vc):

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

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文