Change the Width of UISearchBars on a TableView

前端 未结 1 1309
野性不改
野性不改 2021-01-07 15:19

I am required to create two UISearchBars in my tableView. I want both of them of equal width on top of the table (side-by-side).

I have created two outlets of UISear

相关标签:
1条回答
  • 2021-01-07 16:13

    You are simply reassigning it when you do self.tableView.tableHeaderView= searchBar;. You will have to build a view that contains both the search bars and then set it to the table's header view. Something like this,

    searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 200, 45)];
    zipSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(200, 0, 120, 45)];
    
    searchBar.placeholder = @"School Name";
    zipSearchBar.placeholder=@"Zip";
    
    searchBar.delegate = self;
    zipSearchBar.delegate = self;
    
    UIView * comboView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
    [comboView addSubview:searchBar];
    [comboView addSubview:zipSearchBar];
    
    self.tableView.tableHeaderView= comboView;
    [comboView release];
    
    0 讨论(0)
提交回复
热议问题