UISearchBar animation issue

后端 未结 8 1211
迷失自我
迷失自我 2020-12-08 11:22

I have a UIViewController in which I want to show a tableview with the serchBar.

//viewDidLoad
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,
          


        
8条回答
  •  被撕碎了的回忆
    2020-12-08 12:20

    UITableView *_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,
                                                               64,
                                                               self.view.frame.size.width,
                                                               self.view.frame.size.height)
                                              style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    [self.view addSubview:_tableView];
    
    // adding uisearch bar
    UISearchBar* searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    
    _tableView.tableHeaderView = searchBar;
    
    
    
    //
    UISearchDisplayController* searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
    searchDisplayController.delegate = self;
    searchDisplayController.searchResultsDataSource = self;
    

    and I just embade my controller with UINavigationcontroller and its working quite well..enter image description here

提交回复
热议问题