Ios UISearchBar没有';不要使用正确的tableview

Ios UISearchBar没有';不要使用正确的tableview,ios,uitableview,Ios,Uitableview,我必须为UITableView实现一个搜索栏,但当我搜索某些内容时,显示的表视图不是我在interface builder中设计的表视图,而是一个具有白色背景的表视图 我想要的是保持我在interface builder中设置的背景颜色,而不是在没有显示数据时将单元格缩小到标准高度 怎么做?非常感谢 我正在开发一个最新的应用程序,我从未使用过UISearchBarDisplay,只是没有显示控制器的搜索栏。我在.h文件中为其设置代理,并使用以下方法: //Search Bar code -

我必须为UITableView实现一个搜索栏,但当我搜索某些内容时,显示的表视图不是我在interface builder中设计的表视图,而是一个具有白色背景的表视图

我想要的是保持我在interface builder中设置的背景颜色,而不是在没有显示数据时将单元格缩小到标准高度

怎么做?非常感谢


我正在开发一个最新的应用程序,我从未使用过UISearchBarDisplay,只是没有显示控制器的搜索栏。我在.h文件中为其设置代理,并使用以下方法:

//Search Bar code
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{


}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
     [searchBar resignFirstResponder];        
     [self.tableView reloadData];  
}

这样行吗

我正在开发一个最新的应用程序,我从未使用过UISearchBarDisplay,只是没有显示控制器的搜索栏。我在.h文件中为其设置代理,并使用以下方法:

//Search Bar code
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{


}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
     [searchBar resignFirstResponder];        
     [self.tableView reloadData];  
}

这样行吗

我正在开发一个最新的应用程序,我从未使用过UISearchBarDisplay,只是没有显示控制器的搜索栏。我在.h文件中为其设置代理,并使用以下方法:

//Search Bar code
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{


}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
     [searchBar resignFirstResponder];        
     [self.tableView reloadData];  
}

这样行吗

我正在开发一个最新的应用程序,我从未使用过UISearchBarDisplay,只是没有显示控制器的搜索栏。我在.h文件中为其设置代理,并使用以下方法:

//Search Bar code
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{


}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
     [searchBar resignFirstResponder];        
     [self.tableView reloadData];  
}

这样行吗

尝试将此方法添加到视图控制器:

- (void)searchDisplayController:(UISearchDisplayController *)controller     
   didLoadSearchResultsTableView:(UITableView *)tableView {

    self.searchDisplayController.searchResultsTableView.rowHeight = 100; // your row heigh
    self.searchDisplayController.searchResultsTableView.backgroundView.backgroundColor = [UIColor redColor]; // your BG color
    self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor redColor]; // your BG color

}

尝试将此方法添加到视图控制器:

- (void)searchDisplayController:(UISearchDisplayController *)controller     
   didLoadSearchResultsTableView:(UITableView *)tableView {

    self.searchDisplayController.searchResultsTableView.rowHeight = 100; // your row heigh
    self.searchDisplayController.searchResultsTableView.backgroundView.backgroundColor = [UIColor redColor]; // your BG color
    self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor redColor]; // your BG color

}

尝试将此方法添加到视图控制器:

- (void)searchDisplayController:(UISearchDisplayController *)controller     
   didLoadSearchResultsTableView:(UITableView *)tableView {

    self.searchDisplayController.searchResultsTableView.rowHeight = 100; // your row heigh
    self.searchDisplayController.searchResultsTableView.backgroundView.backgroundColor = [UIColor redColor]; // your BG color
    self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor redColor]; // your BG color

}

尝试将此方法添加到视图控制器:

- (void)searchDisplayController:(UISearchDisplayController *)controller     
   didLoadSearchResultsTableView:(UITableView *)tableView {

    self.searchDisplayController.searchResultsTableView.rowHeight = 100; // your row heigh
    self.searchDisplayController.searchResultsTableView.backgroundView.backgroundColor = [UIColor redColor]; // your BG color
    self.searchDisplayController.searchResultsTableView.backgroundColor = [UIColor redColor]; // your BG color

}


您使用的是UISearchBarDisplay控制器还是UISearchBar?我使用的是UISearchBarDisplay,很抱歉没有提及。UISearchBarDisplay控制器有自己的表视图。这就是你看到的原因。在这种情况下,我通常使用UISearchBar类。您可能需要做一些额外的工作。您使用的是UISearchBarDisplay控制器还是UISearchBar?我使用的是UISearchBarDisplay,很抱歉没有提及。UISearchBarDisplay控制器有自己的tableView。这就是你看到的原因。在这种情况下,我通常使用UISearchBar类。您可能需要做一些额外的工作。您使用的是UISearchBarDisplay控制器还是UISearchBar?我使用的是UISearchBarDisplay,很抱歉没有提及。UISearchBarDisplay控制器有自己的tableView。这就是你看到的原因。在这种情况下,我通常使用UISearchBar类。您可能需要做一些额外的工作。您使用的是UISearchBarDisplay控制器还是UISearchBar?我使用的是UISearchBarDisplay,很抱歉没有提及。UISearchBarDisplay控制器有自己的tableView。这就是你看到的原因。在这种情况下,我通常使用UISearchBar类。你可能需要做一些额外的工作。对不起,你必须回家然后进行测试。这些方法在我必须实现的协议中?是的,在.h文件中,您只需要添加UIViewController。在我的应用程序中,我只是将searchText设置为JSON提要链接的常量变量。然后,当您单击搜索按钮(searchBarSearchButtonClicked方法)时,它会使用更新的JSON链接在tableView中重新加载该数据。这些方法idk中的内容可能与您的不同。我希望在添加每个字母后重新加载数据。您可以尝试将“[self.tableView reloadData];”在textDidChange方法中。但是,不确定这是否是一个好方法。您可能需要找到一种方法来更改searchResultsTableView的背景颜色,并在没有数据时将单元格高度更改为相同。抱歉,必须回家然后进行测试。这些方法在我必须实现的协议中?是的,在.h文件中,您只需要添加UIViewController。在我的应用程序中,我只是将searchText设置为JSON提要链接的常量变量。然后,当您单击搜索按钮(searchBarSearchButtonClicked方法)时,它会使用更新的JSON链接在tableView中重新加载该数据。这些方法idk中的内容可能与您的不同。我希望在添加每个字母后重新加载数据。您可以尝试将“[self.tableView reloadData];”在textDidChange方法中。但是,不确定这是否是一个好方法。您可能需要找到一种方法来更改searchResultsTableView的背景颜色,并在没有数据时将单元格高度更改为相同。抱歉,必须回家然后进行测试。这些方法在我必须实现的协议中?是的,在.h文件中,您只需要添加UIViewController。在我的应用程序中,我只是将searchText设置为JSON提要链接的常量变量。然后,当您单击搜索按钮(searchBarSearchButtonClicked方法)时,它会使用更新的JSON链接在tableView中重新加载该数据。这些方法idk中的内容可能与您的不同。我希望在添加每个字母后重新加载数据。您可以尝试将“[self.tableView reloadData];”在textDidChange方法中。但是,不确定这是否是一个好方法。您可能需要找到一种方法来更改searchResultsTableView的背景颜色,并在没有数据时将单元格高度更改为相同。抱歉,必须回家然后进行测试。这些方法在我必须实现的协议中?是的,在.h文件中,您只需要添加UIViewController。在我的应用程序中,我只是将searchText设置为JSON提要链接的常量变量。然后,当您单击搜索按钮(searchBarSearchButtonClicked方法)时,它会使用更新的JSON链接在tableView中重新加载该数据。这些方法idk中的内容可能与您的不同。我希望在添加每个字母后重新加载数据。您可以尝试将“[self.tableView reloadData];”在textDidChange方法中。不过,我不确定这是否是一个好办法。你可能必须找到一个办法