jharr100
jharr100

Reputation: 1469

Attaching an event to UIWebView ScrollViewer prevents zooming

Whenever I attach an event to UIWebView's ScrollViewer to detect scrolling it prevent the UIWebView from zooming in and out. However, scrolling up and down still works. I am viewing a PDF in the UIWebView.

I've tried these events:

Scrolled ScrolledAnimationEnded ZoomingEnded DidZoom

For example I tried:

ContractWebView.ScrollView.Scrolled += (object sender, EventArgs e) =>{
   Debug.WriteLine("Scrolled");
};

I have event tried an empty event body.

Upvotes: 1

Views: 299

Answers (1)

Adam Ivancza
Adam Ivancza

Reputation: 2529

Did you tried to set a delegate to the ScrollView instead of using the events? Something like this:

public class ScrollViewDelegate : UIScrollViewDelegate
{
    public override void Scrolled(UIScrollView scrollView)
    {
        Console.WriteLine("Scrolled");
    }
}

ContractWebView.ScrollView.Delegate = new ScrollViewDelegate();

EDIT: Here is the complete code that I used for the test and it worked me:

public class IPadViewController1 : UIViewController
{
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        UIWebView webview = new UIWebView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height));
        webview.ScrollView.Delegate = new ScrollViewDelegate();
        webview.ScalesPageToFit = true;
        View.AddSubview(webview);

        string urlAddress = "http://google.com";
        NSUrl url = NSUrl.FromString(urlAddress);
        //URL Requst Object
        NSUrlRequest requestObj = NSUrlRequest.FromUrl(url);
        webview.LoadRequest(requestObj);
    }
}

Upvotes: 3

Related Questions