First I build a view add to tableview as tableHeaderView
UIView *mainHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 300)];
[self.mainViewTableView setTableHeaderView:mainHeaderView];
I could adjust the Height of mainHeaderView but I cant adjust Y position of this headView.
And I trying to add a sub view:
self.searchForShop = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.mainViewTableView.tableHeaderView.frame.size.width, 44)];
[self.mainViewTableView addSubview:self.searchForShop];
Run app and found the subview's width is longer than tableHeadView. Do view debug and found the subview is 16 width more than tableHeadView(I run in iphone5s).
How to fix it?