UITeViewBtroller中的UISearchBar? [英] UISearchBar in UITableViewController?

查看:84
本文介绍了UITeViewBtroller中的UISearchBar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 TableView 中添加 SearchBar 。我只是将 UISearchBar 拖到IB中的 UITableView 的标题中,然后用我的 UITableView 。

I want to add a SearchBar to my TableView. I just dragged the UISearchBar to the header of an UITableView in IB, and it scrolled with my UITableView.

我现在更改为使用 UITableViewController ,当我拖动时 UISearchBar UITableView 的标题
中,它随 UITableViewController一起提供,它根本不显示。

I changed to use UITableViewController now, and when I drag an UISearchBar in the header of the UITableView which is provided with the UITableViewController, it doesn't show up at all.

有诀窍吗?

亲切的问候

推荐答案

你可以通过编程方式完成

You can do it programmatically

UISearchBar *tempSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 0)];
self.searchBar = tempSearchBar;
[tempSearchBar release];
self.searchBar.delegate = self; 
[self.searchBar sizeToFit];  
self.tableView.tableHeaderView = self.searchBar;  

希望这会有所帮助。

这篇关于UITeViewBtroller中的UISearchBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆