iOS界面生成器:y位置更改时,搜索栏不会显示

iOS界面生成器:y位置更改时,搜索栏不会显示,ios,uitableview,uiview,Ios,Uitableview,Uiview,我有一个UITableView,在UIview中有一个搜索栏。我更改了Y位置,以便将UITableView向下移动,但当我加载应用程序时,Y位置似乎被重置并向上移动。我该如何解决这个问题 UITableView/搜索栏在UIView中下移: 应用加载后的UITableView/搜索栏: 我想通过将表视图放在tableview的tableHeaderView属性而不是封闭的UIView来避免表视图完全覆盖搜索栏的问题-我认为这是一种相当标准的方法: UISearchBar *searchBar

我有一个UITableView,在UIview中有一个搜索栏。我更改了Y位置,以便将UITableView向下移动,但当我加载应用程序时,Y位置似乎被重置并向上移动。我该如何解决这个问题

UITableView/搜索栏在UIView中下移:

应用加载后的UITableView/搜索栏:


我想通过将表视图放在tableview的
tableHeaderView
属性而不是封闭的
UIView
来避免表视图完全覆盖搜索栏的问题-我认为这是一种相当标准的方法:

UISearchBar *searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
self.tableView.tableHeaderView = searchBar;
tableview中数据的存在与否不应产生任何影响。

继续工作:

_recipeList = [[RecipeViewController alloc] initWithStyle:UITableViewStylePlain];

//Create a frame for the current table view controller
CGRect frame = _recipeList.view.frame;
frame.origin.x = 0;
frame.origin.y = 57;
_recipeList.view.frame = frame;

[self.view addSubview:_recipeList.view];

您可能必须以编程方式强制表视图向下移动,这也可能是由于表视图中没有数据,因此它隐藏了标题?好的,我将尝试以编程方式向下移动它。另外,将加载一些数据以查看发生了什么。