Objective c UITableView没有';通过UISearchBar过滤后,t向上滚动

Objective c UITableView没有';通过UISearchBar过滤后,t向上滚动,objective-c,uitableview,ios7,scroll,Objective C,Uitableview,Ios7,Scroll,我有一个UISearchbar和UITableView。我在创建的tableview中显示结果 通过我在UISearchbar中键入的NSString筛选tableview之后,我无法使tableview滚动到顶部。如果我在过滤后滚动到tableview上的另一个点,并继续在搜索栏中键入,则tableview滚动仍在同一点上。我希望tableview滚动条位于顶部 我试过这些: [tableview scrollRectToVisible:CGRectMake(0, 0, 1, 1) anima

我有一个UISearchbar和UITableView。我在创建的tableview中显示结果

通过我在UISearchbar中键入的NSString筛选tableview之后,我无法使tableview滚动到顶部。如果我在过滤后滚动到tableview上的另一个点,并继续在搜索栏中键入,则tableview滚动仍在同一点上。我希望tableview滚动条位于顶部

我试过这些:

[tableview scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
tableview.contentOffset=CGPointMake(0,0);
tableview.scrollsToTop=true;
我把过滤功能叫进来

-(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString


我应该怎么做才能解决这个问题呢?

我怀疑无论您从何处调用“
scrollRectToVisible:
”,您的“
表视图
”都是空的

试试这个:

if(tableview)
{
    [tableview scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES]; 
    tableview.contentOffset=CGPointMake(0,0);
    tableview.scrollsToTop=true;
} else {
    NSLog(@"tableview is null, I need to use a property for my tableview");
}

Tableview从不为空。
if(tableview)
{
    [tableview scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES]; 
    tableview.contentOffset=CGPointMake(0,0);
    tableview.scrollsToTop=true;
} else {
    NSLog(@"tableview is null, I need to use a property for my tableview");
}