UISearchController search bar overlap first cell when active

前端 未结 7 2486
慢半拍i
慢半拍i 2020-12-21 08:52

I am using UISearchController to search for data in my tableview. I am not using table view controller. I would like to hide the navigation bar when my search b

7条回答
  •  半阙折子戏
    2020-12-21 09:52

    I managed to resolve this issue by combining RJiryes answer with scroll to top.

    -(void)willPresentSearchController:(UISearchController *)searchController{
    
         [self.contactsTableView setContentInset:UIEdgeInsetsMake(20, 0, 0, 0)];
         [self.contactsTableView setContentOffset:CGPointMake(0.0f, -self.contactsTableView.contentInset.top) animated:YES];
     }
    
    -(void)willDismissSearchController:(UISearchController *)searchController{
    
         [self.contactsTableView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    }
    

提交回复
热议问题