Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView ScrollToRowatineXpath不';t如果第一行只有一项,则滚动到第一行_Ios_Uitableview - Fatal编程技术网

Ios UITableView ScrollToRowatineXpath不';t如果第一行只有一项,则滚动到第一行

Ios UITableView ScrollToRowatineXpath不';t如果第一行只有一项,则滚动到第一行,ios,uitableview,Ios,Uitableview,我在iPhone上实现了一个tableView,可以使用搜索栏进行搜索。我试图模仿第一次加载时在我的tableView中隐藏搜索栏的效果 当tableView包含多行时,该行为是预期的。但是,当只有一行时,它不会滚动到第一行。它显示了搜索栏 - (void)viewDidLoad { [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]

我在iPhone上实现了一个tableView,可以使用搜索栏进行搜索。我试图模仿第一次加载时在我的tableView中隐藏搜索栏的效果

当tableView包含多行时,该行为是预期的。但是,当只有一行时,它不会滚动到第一行。它显示了搜索栏

- (void)viewDidLoad {
    [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] 
                          atScrollPosition:UITableViewScrollPositionTop
                                  animated:NO];
}

事实上,我不明白所有的事情(可能是错误的,当你把单元格添加到表中时-搜索栏在哪里,在哪个单元格中?) 但是你可以试试

[self.tableView scrollRectToVisible:CGRectMake(0, yValue, 10, 10) animated:YES];