UISearchController 使用 背景色/偏移/结果控制器 push 有关的 问题?

代码链接
问题1 :当将搜索栏设置成 tableHeaderView 的时候,
[_tableView setTableHeaderView:_searchController.searchBar];

clipboard.png

向下拉,编辑的位置的颜色如何设置?

问题2: 需求是要搜索栏停留在 nav 下面, 使用时会有问题

clipboard.png

查看这是的层级结构

clipboard.png

求救!

目前是用 ChenYilong 的 项目思路搞的,但是版本适配挺烦的,
模仿iPhone短信聊天里的搜索框样式,点击搜索后,搜索框平滑移动到导航栏上

问题3:
在结果控制器里,想 push 到其他 VC 里,发现 nav 是 nil,

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UINavigationController *nav = self.navigationController;
  
    UIViewController *vc = [[UIViewController alloc]init];
    [nav pushViewController:vc animated:YES];
}
阅读 3.8k
1 个回答

1、tableView 有一个backview,可以设置这个颜色,直接设置不管用,要重新赋值一个,像这样。

    UIView *tableBackgroundView = [[UIView alloc]initWithFrame:self.tableView.bounds];
    tableBackgroundView.backgroundColor = GL_BACKGROUD_COLOR;
    self.tableView.backgroundView = tableBackgroundView;

2、没有复现
3、searchViewController 是present出来的,nav当然是nil。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题