I have a UIWebView
with some content and I need to make its scroll indicator visible for a short time (like [UIScrollView flashScrollIndicators]
).
我有一个带有一些内容的UIWebView,我需要让它的滚动指示器在短时间内可见(如[UIScrollView flashScrollIndicators])。
Any idea how to do this?
知道怎么做吗?
2 个解决方案
#1
12
Starting iOS 5.0 onwards, one can now customize the scrolling behavior of UIWebView by accessing the 'scrollview' property to achieve the desired functionality:
从iOS 5.0开始,现在可以通过访问“scrollview”属性来自定义UIWebView的滚动行为,以实现所需的功能:
[webView.scrollView flashScrollIndicators];
#2
2
There's no real way of doing this via a published API, however I think that in this case it's OK to guess the UIScrollView
subview, so long as you make sure your application doesn't crash if you can't find the UIScrollView
:
没有真正的方法通过已发布的API执行此操作,但我认为在这种情况下可以猜测UIScrollView子视图,只要您确定如果找不到UIScrollView您的应用程序不会崩溃:
UIView* scrollView = [webView.subviews objectAtIndex:0];
if ([scrollView isKindOfClass:[UIScrollView class]) {
[((UIScrollView*)scrollView) flashScrollIndicators];
} else {
// If Apple changes the view hierarchy you won't get
// a flash, but that doesn't matter too much
}
EDIT: The above will not work because the first subview of a UIWebView
is a UIScroller
, not a UIScrollView
(my memory might be playing tricks on me). Perhaps try the following?
编辑:以上将无法正常工作,因为UIWebView的第一个子视图是UIScroller,而不是UIScrollView(我的记忆可能在玩我的技巧)。也许尝试以下?
UIView* uiScroller = [webView.subviews objectAtIndex:0];
if ([uiScroller respondsToSelector:@selector(displayScrollerIndicators)]) {
[((UIScrollView*)uiScroller) performSelector:@selector(displayScrollerIndicators)];
} else {
// If Apple changes the view hierarchy you won't get
// a flash, but that doesn't matter too much
}
#1
12
Starting iOS 5.0 onwards, one can now customize the scrolling behavior of UIWebView by accessing the 'scrollview' property to achieve the desired functionality:
从iOS 5.0开始,现在可以通过访问“scrollview”属性来自定义UIWebView的滚动行为,以实现所需的功能:
[webView.scrollView flashScrollIndicators];
#2
2
There's no real way of doing this via a published API, however I think that in this case it's OK to guess the UIScrollView
subview, so long as you make sure your application doesn't crash if you can't find the UIScrollView
:
没有真正的方法通过已发布的API执行此操作,但我认为在这种情况下可以猜测UIScrollView子视图,只要您确定如果找不到UIScrollView您的应用程序不会崩溃:
UIView* scrollView = [webView.subviews objectAtIndex:0];
if ([scrollView isKindOfClass:[UIScrollView class]) {
[((UIScrollView*)scrollView) flashScrollIndicators];
} else {
// If Apple changes the view hierarchy you won't get
// a flash, but that doesn't matter too much
}
EDIT: The above will not work because the first subview of a UIWebView
is a UIScroller
, not a UIScrollView
(my memory might be playing tricks on me). Perhaps try the following?
编辑:以上将无法正常工作,因为UIWebView的第一个子视图是UIScroller,而不是UIScrollView(我的记忆可能在玩我的技巧)。也许尝试以下?
UIView* uiScroller = [webView.subviews objectAtIndex:0];
if ([uiScroller respondsToSelector:@selector(displayScrollerIndicators)]) {
[((UIScrollView*)uiScroller) performSelector:@selector(displayScrollerIndicators)];
} else {
// If Apple changes the view hierarchy you won't get
// a flash, but that doesn't matter too much
}