1
我有一個PFQueryTableViewController,它被設置爲實例化和呈現一個新的視圖控制器,在一個UINavigationViewController內,當一個行被選中。介紹另一個視圖控制器滾動UITableView頂部
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self objectAtIndexPath:indexPath]) { // Check our object exists
MyNewViewController *card = [[MyNewViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:card];
[nav.navigationBar configureFlatNavigationBarWithColor:[UIColor pomegranateColor]];
[self presentViewController:nav animated:YES completion:^{}];
}
else { // Otherwise, do what we would have done.
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
}
}
當我選擇了某一行,表視圖滾動(非動態)一路到頂部,就在新的視圖控制器之前提出。這是第一個問題,因爲它使用戶很難跟蹤它們的位置。
第二個問題是,當我退出新的視圖控制器,返回到表視圖控制器,我不能從第一個單元格向下滾動。它會彈跳,我可以看到第二個單元的一些,但它不會降低。重新加載表格會導致滾動再次運行。
如何防止滾動回頂端,爲什麼在滾動到頂端後限制滾動?
謝謝!我會給它一個鏡頭。只是爲了我的理解,是presentViewController做到這一點的錯誤方式? – tghw
我不認爲你的解決方案是錯誤的。我認爲你應該嘗試我的解決方案:)。 – stosha
或者你可以嘗試調用方法[tableView deselectRowAtIndexPath:indexPath animated:NO];在presentviewController之前保存當前indexPath並在返回後恢復。 – stosha