gpt4 book ai didi

iphone - 在没有 UITableView 的情况下使用 UISearchBar

转载 作者:行者123 更新时间:2023-12-03 20:07:39 25 4
gpt4 key购买 nike

我正在查看Apple提供的TableSearch示例代码。在 cellForRowAtIndexPath 方法中,根据是否正在搜索某个项目,表会更新。我想知道是否可以在不使用 UITableView 的情况下实现这种类型的功能。我正在尝试通过水平显示卡片来复制该功能。大声思考,假设这是可能的,我会

  • 让水平显示的卡片具有一个委托(delegate),当在搜索栏中输入内容时可以调用该委托(delegate)。

  • 我是否可以子类化 UISearchBar 来添加此委托(delegate),这样我就可以这样做类似于 searchBar.myNewDelegate =horizo​​ntalDisplay;

最佳答案

无需子类化,只需使您的 Controller 符合 UISearchBarDelegate 协议(protocol),您就可以实现所有文本更改方法来执行您想要的操作。 http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UISearchBarDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UISearchBarDelegate

关于iphone - 在没有 UITableView 的情况下使用 UISearchBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8508975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com