文件名称:SearchBar和tableView 组合并且不遮住状态栏
文件大小:105KB
文件格式:ZIP
更新时间:2020-01-27 12:51:15
SearchBar tableView
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; }
【文件预览】:
SearchBarDemo
----.DS_Store(6KB)
----SearchBarDemoTests()
--------Info.plist(733B)
--------SearchBarDemoTests.m(912B)
----SearchBarDemo.xcodeproj()
--------project.xcworkspace()
--------xcuserdata()
--------project.pbxproj(21KB)
----.git()
--------info()
--------index(2KB)
--------objects()
--------HEAD(23B)
--------config(137B)
--------refs()
--------hooks()
--------description(73B)
----SearchBarDemoUITests()
--------Info.plist(733B)
--------SearchBarDemoUITests.m(1KB)
----SearchBarDemo()
--------ViewController.m(8KB)
--------SearchBarDemo.xcdatamodeld()
--------Info.plist(1KB)
--------main.m(329B)
--------Base.lproj()
--------ViewController.h(210B)
--------AppDelegate.h(633B)
--------Assets.xcassets()
--------AppDelegate.m(6KB)