views:

1163

answers:

1

Hi, all I have UIWebView with some content And i need to make its scroll indicator visible for a short time (like [UIScrollView flashScrollIndicators])

Any ideas, how to do this?

Thanks.

+1  A: 

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:

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?

UIView* uiScroller = [webView.subviews objectAtIndex:0];
if ([uiScroller respondsToSelector:@selector(displayScrollerIndicators)]) {
  [((UIScrollView*)uiScroller) performSelector:@(displayScrollerIndicators)];
} else {
  // If Apple changes the view hierarchy you won't get
  // a flash, but that doesn't matter too much
}
Nathan de Vries
UIWebView hasn't "UIScrollView" subviewIt has only "UIScroller" subview And UIScroller hasn't flashScrollIndicators method ((
oxigen
Has that always been the case? I seem to remember this working in iPhone OS 2.x.
Nathan de Vries
you won't get this approved since UIScroller is private API.
stigi