Adding UISearchBar into tableView header as subview

前端 未结 2 814
梦谈多话
梦谈多话 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:50

    Just follow the simple steps here..

    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;
      }
      

提交回复
热议问题