UI搜索栏问题
我正在尝试将 UISearchbar 添加到表头视图中。 我的笔尖上有图标并已连接插座。
现在在 viewDidLoad 中,我正在写 self.tableView.tableHeaderView = searchbar
如果我在 viewDidLoad 中创建一个本地变量,它就会显示出来。但不是outlet 或ivar 的。
但由于某种原因,UISearchbar 没有显示在表格中。 我不确定问题是什么。 UISearchbar 不能在 viewDidLoad 中设置
还是其他东西?
请帮忙。
I am trying to add a UISearchbar to table header view.
I have the icon in nib and have connected the outlets.
Now in viewDidLoad, I am writing
self.tableView.tableHeaderView = searchbar
If i create a local var inside viewDidLoad, it shows up. But not the outlet or ivar one.
But for some reason, the UISearchbar does not get displayed in the table.
I am not sure what the issue is. Can a UISearchbar not be set in viewDidLoad
OR is it something else?
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是在 IB 中插入了 SearchBarController 还是仅插入了 SearchBar 对象?您必须选择要与之交互的 SearchBarController。
放入您的
tableView:didSelectRowAtIndexPath:
或tableView:accessoryButtonTappedForRowWithIndexPath:
方法:您还可以尝试向您的视图添加一个带有红色背景颜色的空白 UIView 并查看它是否显示(所以无论如何你都会知道笔尖是否已加载)
did you insert the SearchBarController or just the SearchBar object in IB? You have to choose the SearchBarController to interact with.
put in your
tableView:didSelectRowAtIndexPath:
ortableView:accessoryButtonTappedForRowWithIndexPath:
method:you can also try and add a blank UIView with red backgroundColor to your view and see if its displayed (so you would know if the nib is loaded anyway)