将UISearchBar作为子视图添加到tableView头中 [英] Adding UISearchBar into tableView header as subview

查看:75
本文介绍了将UISearchBar作为子视图添加到tableView头中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将自定义标头添加到 UITableView ,它有一些按钮和 UISearchBar
问题是,当我尝试使用searchBar时,我收到一条消息:

I'm trying to add a custom header to UITableView, that has some buttons and an UISearchBar. The problem is, that when I try to use searchBar I get a message:

设置表的第一个响应者视图但是我们不知道它的类型(单元格/页眉/页脚)

有没有人遇到过这样的问题?

Has anyone encounter such problem?

推荐答案

只需按照这里的简单步骤进行..

Just follow the simple steps here..


  1. 创建一个属性对于'。''文件中的mySearchBar并进行综合。

  2. 在viewDidLoad / viewDidAppear方法中设置其属性(或者你可以在界面生成器中完成)

  3. 使用以下委托方法将其设置为表格视图的标题...

  1. create a property for mySearchBar in your '.h' file and synthesize.
  2. set its attributes in viewDidLoad/viewDidAppear method (or u can simply do it in the Interface Builder)
  3. Use the following delegate method to set it as the header of your table view...

– (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {                 
        return self.mySearchBar;
}


这篇关于将UISearchBar作为子视图添加到tableView头中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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