Adding UISearchBar into tableView header as subview

前端 未结 2 792
梦谈多话
梦谈多话 2021-01-18 17:26

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 ge

2条回答
  •  野的像风
    2021-01-18 17:51

    Are you adding to the table via:

    [self.tableView addSubview:customView]
    

    If so, that could be your error. Adding subviews to UITableView requires that you add them either as header, footer, or cell explicitly. Try:

    self.tableView.tableHeaderView = customView
    

提交回复
热议问题