Friday, September 28, 2012

How to access the scrollview inside an UIWebView


                       How to access the scrollview inside an UIWebView

Every UIWebView contains a scrollview, so if anybody wants to access that scrollview he/she  can do this by following way.

  if( [self.webView respondsToSelector:@selector(scrollView)] ) {
        UIScrollView *sv =  [self.webView performSelector:@selector(scrollView)];
        [sv setDecelerationRate:UIScrollViewDecelerationRateNormal ];
        for( UIImageView *innerView in sv.subviews ) {
            if( [innerView isKindOfClass:[UIImageView class]] ) {
                innerView.hidden = YES;
            }
        }
        NSLog(@"ios 5+");
    }
    else
    {
        NSLog(@"ios 4");
        for( UIScrollView *view in [self.webView subviews] ) {
            if( [view isKindOfClass:[UIScrollView class]] ) {
                [view setDecelerationRate:UIScrollViewDecelerationRateNormal];//0.998000
                for( UIImageView *innerView in [view subviews] ) {
                    if( [innerView isKindOfClass:[UIImageView class]] ) {
                        innerView.hidden = YES;
                    }
                }
            }
        }
    }

No comments:

Post a Comment