iPhone/Objective-C - UISearchBar 响应触摸但不显示键盘
我有一个用于显示评论的视图。您显然可以从这个角度发表评论。就像 Facebook 应用程序(签入视图)一样,视图底部有一个评论栏。我想在单击看起来像 UISearchBar 的内容时实现相同的功能(不包括模式,我已经完成了)。
我想我只需要知道 UISearchBar 上接受触摸的最佳方法是什么,而实际上没有键盘弹出窗口(我会假设它返回 null 或可能在特定委托方法上返回某些内容?)。相反,我想调用一个简单地呈现我的模态视图的操作。因此,我实际上不会允许用户将文本点击到 UISearchBar 中,他们将在模式上的 UITextField 中执行此操作。
希望这是有道理的,当然,非常感谢您的回答。
I have a view that's used to display Comments. You can obviously comment from this view. Just like the Facebook application (checkin view) where there's a Comment bar on the bottom of the view. I would like to achieve the same functionality (not including the modal, which I've done already) when clicking on what looks like a UISearchBar.
I guess I just need to know what the best method for accepting touches are on a UISearchBar without actually having the keyboard popup (I would assume it's returning null or something on a specific delegate method perhaps?). Instead I'd like to call an action that simply presents my modal view. So I'm not actually going to allow the user to tap text into the UISearchBar, they'll do that within a UITextField on the modal.
Hope this makes sense and of course, answers are greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么你为什么要首先使用 UISearchBar 呢?我会选择一个自定义视图来绘制看起来像 UISearchBar 的东西,或者更简单,只使用 UIButton 和看起来像 UISearchBar 的图像。
如果您确实想使用 UISearchBar,我想您可以将其子类化并覆盖 TouchBegan:,但我认为这不是一个好主意。
Why do you want to use UISearchBar in the first place then? I'd go for either a custom view that draws something that looks like a UISearchBar, or, even simpler, just use a UIButton with an image that looks like a UISearchBar.
In case you really wanted to use the UISearchBar I guess you could subclass it and overwrite touchesBegan:, but I don't think this a good idea.