Aayush Pandey Aayush Pandey - 25 days ago 7
iOS Question

iOS | Need to place a overlay over the webView without blocking the user interaction to webView

iOS | Need to place a overlay over the webView without blocking the user interaction to webView like scrolling on the webView which is behind the overlay

Answer

You need to add a UiView or any subclass of UIView like button. and than just set userInteraction to false. What happens in chain responder if some view rejects to handle event it is forwarded to its immediate view. Hope this will work for you

  1. Add a webView to project

  2. Place a Overlay View (UIView or UIButton) over the webView in StoryBoard

  3. Set USER-INTERACTION of the overlay view to false.

    NSString *urlString = @"http://www.facebook.com";
    NSURL *url = [NSURL URLWithString:urlString];
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
    [_webView loadRequest:urlRequest];
    _btn.userInteractionEnabled = NO;
    _overlayView.userInteractionEnabled = NO