ios中不出现搜索栏 [英] Search bar does not appear in ios

查看:34
本文介绍了ios中不出现搜索栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有页面控制器,我在其中添加了两个表格视图.在添加的 tableview 搜索控制器的每个标题中,viewForHeader 方法也返回最近"和其他"视图.

I have page controller in which I added two tableviews. In each header of tableview search controller added, also viewForHeader method return "Recent" and "Other" view's.

我的问题是点击搜索栏时没有出现搜索栏.它似乎向上移动,我看不到我在那里输入的内容.搜索栏可能隐藏在连接"、消息"选项卡后面.

My problem is the search bar does not appear when the search bar clicked. It appear to move up, I cant see what I am typing there. There may be the possibility that the search bar is hidden behind "Connection","Message" tab.

当键盘成为第一响应者时,如何将搜索栏保持在同一位置?任何帮助将不胜感激.

How to keep search bar at same position when keyboard become first responder? any help will appreciated.

推荐答案

您是否在 ViewDidLoad

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;

[self.view bringSubviewToFront:searchBarRef]; // add this line where ever u need..!

-(void)loadSearchBar {

    searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 64)];
    searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
    searchDisplayController.delegate = self;
    searchDisplayController.searchResultsDataSource = self;

    self.tableView.tableHeaderView = searchBar; 

}

ViewDidLoad 处调用这个 loadSearchBar 方法.

Call this loadSearchBar method at ViewDidLoad.

这会将搜索栏添加到 TableView.

This will add search bar to TableView.

这篇关于ios中不出现搜索栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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