UI搜索栏问题

发布于 2024-10-08 12:44:18 字数 299 浏览 0 评论 0原文

我正在尝试将 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 技术交流群。

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

发布评论

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

评论(1

若无相欠,怎会相见 2024-10-15 12:44:18

您是在 IB 中插入了 SearchBarController 还是仅插入了 SearchBar 对象?您必须选择要与之交互的 SearchBarController。

放入您的 tableView:didSelectRowAtIndexPath:tableView:accessoryButtonTappedForRowWithIndexPath: 方法:

MyVC *vc = [[MyVC alloc]initWithNibName:@"MyVCNibName" andBundle:nil];
[self.view presentModalViewController:vc animated:YES];
[vc release];

您还可以尝试向您的视图添加一个带有红色背景颜色的空白 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: or tableView:accessoryButtonTappedForRowWithIndexPath: method:

MyVC *vc = [[MyVC alloc]initWithNibName:@"MyVCNibName" andBundle:nil];
[self.view presentModalViewController:vc animated:YES];
[vc release];

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)

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