自动滚动到顶部在UITableView中不起作用 [英] Automatic scroll to top doesn't work in UITableView

查看:129
本文介绍了自动滚动到顶部在UITableView中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常在点击屏幕顶部时,桌面视图一直滚动到顶部。出于某种原因,这在我的一个视图控制器中不起作用。

usually when tapping the top of the screen the tableview scrolls all the way to the top. For some reason this doesn't work in one of my view controllers.

hirarchy如下:

The hirarchy is as follows:

UIView

- > WebView

- > TableView

-----> SearchBar

SearchDisplayController。

UIView
-> WebView
-> TableView
----->SearchBar
SearchDisplayController.

我想我已经把所有东西都正确地连接起来了(datasource,delegate,...)。我有一个类似的视图控制器,一切正常。唯一的区别似乎是WebView,它在视图控制器中缺失,其中点击并滚动到顶部工作...

I think I have everything hooked up correctly (datasource, delegate, ...). I have a similar view controller where everything works. The only difference seems to be WebView, which is missing in the view controller where the tap-and-scroll-to-top works...

任何想法?

祝你好运,
Sascha

Best regards, Sascha

推荐答案

你需要禁用除了一个可滚动视图之外的所有视图上的 scrollsToTop 。由于 UITableView UIScrollView 的后代,因此很容易做到。但是,如果要在webview上禁用它,则有点棘手。这似乎有效:

You need to disable scrollsToTop on all but one of the scrollable views. Since UITableView is a descendant of UIScrollView, it's easy to do. However, if you want to disable it on the webview, it's a little trickier. This seems to work:

[webView.subviews objectAtIndex:0].scrollsToTop = NO;

但这有点不确定,因为它在webview的未记录部分中徘徊。如果Apple决定重新安排子视图,它可能会停止工作。

But that is a little iffy since it's poking around in undocumented parts of the webview. It may stop working if Apple decides to rearrange the subviews.

这篇关于自动滚动到顶部在UITableView中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆