Wednesday 15 June 2011

ios - UIWebView scrollView not calling scrollViewDidScroll on touch -


I'm developing for iOS 6, and I'm working in a way in the toolbar at the top of a UIWebView Which will be reduced as you scroll up on the UIWebView.

My thought is that I can send the UIScrollView UIWebView message to my UIViewController, which is to set the representative of animate the barriers on the toolbar at the top

However, scrollViewDidScroll: does not seem to call the method, which confuses me.

Now, there are many other questions that are similar to this, most of whom forget to set representative property on Scroll Weave ...

  • - Representative
  • - Representative
  • - Representative?
  • - Representative
  • - And ... Rep.

    No need to say, I am setting up a representative. Some code pieces:

    SDDefinitionViewController.h:

      @interface SDDefinitionViewController: UIViewController & LT; UIWebViewDelegate, UIScrollViewDelegate & gt; ...   

    SDDefinitionViewController.m:

      ... - (zero) viewDidload {{Super ViewDoadload}; // Setup an additional after loading the view [self load definitions]; // Hold the context of ScrollView so that we can set the delegate and then use those method calls to animate the top bar. Self.scrollView = self.webView.scrollView; Self.scrollView.delegate = self; Self.lastScrollViewVerticalOffset = 0; } ... - (zero) scrollViewDidScroll: (UIScrollView *) scrollView {// (code) & lt; = Never called ... ...   

    And, to close it, I did some debugger console actions:

      ( Lldb) po $ self 0 $ 0x095c0600 & lt; SDDefinitionViewController: 0x95c0600 & gt; (LLDB) PS self.scrollView $ 1 = 0x0954e8d0 & lt; _UIWebViewScrollView: 0x954e8d0; Frame = (0; 1024 596); Clip Tubons = Yes; Autoresc = h; Inspirator = & lt; NSArray: 0x954ec50 & gt; Layer = & lt; CALayer: 0x954eab0 & gt;; Content Offset: {0, 0} & gt; (LLDB) PS self.scrollView.delegate $ 2 = 0x095c0600 & lt; SDDefinitionViewController: 0x95c0600 & gt;   

    Therefore, the representative is definitely set correctly, nothing is being released randomly.

    Finally, I called the program called setContentOffset on self.scrollView and the representative method but this is actually Is not useful because I have to find out that the user is scrolling with a gesture.

    So, what is the scoop on it? Why scrollview will not call your representative methods

    Edit:

    So, looking at my app with, I think my UIWebView is a _UIWebViewScrollView as a subview, And it has a UIWebBrowserView below UIWebBrowserView is exactly the same size as UIWebView ...

    It may be that UIWebViewScrollView is a normal content that it offset and so on, that webkit scrolls Or is not doing something? After

    itemprop = "text">

    UIWebView internally applies UIScrollViewDelegate < / Code> Methods It is unlikely that UIScrollViewDelegate will be re-specified for other objects except the current UIWebView object. So, I got a small job around me. You can apply the UIScrollViewDelegate methods to UIWebView in that category and do not forget to forward the method to super or other unexpected behavior.

    In this way I solved the problem: Click . @Interface webview: UIWebView @property (nonatomic, weak) NSObject & lt; UIScrollViewDelegate & gt; * MScrollDelegate; @end //// WebView.m file #import "WebView.h" @ synthesize mScrollDelegate; @ Implementation WebView - (id) init {self = [super init]; If (self) {self.scrollView.delegate = self; } Healthy return; } ///// scrollViewDidScroll method, besides, I'm forwarding this super class to UIWebView - (Zero) scrollViewDidScroll: (UIScrollView *) scrollview {[Super scrollViewDidScroll: scrollview]; If ([MS. MScrollDelegate responds to itself] Tselector: @sillector (scrollwiddscroll :)) {[self. MScrollDelegate scrollViewDidScroll: scrollView]; } NSLog (@ "scrollViewDidScroll"); } @end

    and make sure that your self.webview should be of type WebView . In SDDefinitionViewController.m

      self.webView.mScrollDelegate = self;   

    Your scrollViewDidScroll method will now be called in SDDefinitionViewController.m

    No comments:

    Post a Comment