Reputation: 115
When I add DraggingStarted or any other ScrollView events to webview, then Zooming got disabled.
string urlAddress = "http://google.com";
NSUrl url = NSUrl.FromString(urlAddress);
//URL Requst Object
NSUrlRequest requestObj = NSUrlRequest.FromUrl(url);
webview.LoadRequest (requestObj);
//Once added following line zoom is stopped
webview.ScrollView.DraggingStarted += (object sender, EventArgs e) => {};
I have tried following but no luck
webview.ScrollView.ViewForZoomingInScrollView = (scrollView) => {
return webview;
};
Upvotes: 0
Views: 1835
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 DraggingStarted(UIScrollView scrollView)
{
Console.WriteLine("DraggingStarted");
}
}
webview.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: 1