ios7 demo下载 searchbar与状态栏重叠已修复。 关键代码: -(void)viewDidLoad{ [super viewDidLoad]; // self.table.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];//去除多余行 //设置table内容的位置,要在创建searchbar之前设置 if (self.table.style == UITableViewStylePlain) { UIEdgeInsets contentInset = _table.contentInset; contentInset.top = 25; [_table setContentInset:contentInset]; } //创建search _searchcontroller = [[UISearchController alloc] initWithSearchResultsController:nil]; _searchcontroller.searchResultsUpdater = self; _searchcontroller.dimsBackgroundDuringPresentation = NO; _searchcontroller.hidesNavigationBarDuringPresentation = NO; _searchcontroller.searchBar.frame = CGRectMake(self.searchcontroller.searchBar.frame.origin.x, self.searchcontroller.searchBar.frame.origin.y, self.searchcontroller.searchBar.frame.size.width, 44.0); self.searchcontroller.searchBar.delegate = self; self.searchcontroller.searchBar.keyboardType = UIKeyboardTypeDefault; CGRect r= self.table.tableHeaderView.bounds; r.origin.y=-10; self.table.tableHeaderView.bounds=r; self.table.tableHeaderView = self.searchcontroller.searchBar; }
- 1
- lli002017-08-18很好的解决了问题, 附上swift的代码: if self.tableView.style == UITableViewStyle.plain { var contentInset = tableView.contentInset contentInset.top = 20 self.tableView.contentInset=contentInset }
- 粉丝: 52
- 资源: 6
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助