当我将DraggingStarted或任何其他ScrollView事件添加到webview时,Zooming被禁用。
string urlAddress = "http://google.com";
NSUrl url = NSUrl.FromString(urlAddress);
//URL Requst Object
NSUrlRequest requestObj = NSUrlRequest.FromUrl(url);
webview.LoadRequest (requestObj);
//在线条缩放停止后添加
webview.ScrollView.DraggingStarted += (object sender, EventArgs e) => {};
我试过以下但没有运气
webview.ScrollView.ViewForZoomingInScrollView = (scrollView) => {
return webview;
};
答案 0 :(得分:1)
您是否尝试将代理设置为ScrollView而不是使用事件?像这样:
public class ScrollViewDelegate : UIScrollViewDelegate
{
public override void DraggingStarted(UIScrollView scrollView)
{
Console.WriteLine("DraggingStarted");
}
}
webview.ScrollView.Delegate = new ScrollViewDelegate();
修改强> 这是我用于测试的完整代码,它对我有用:
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);
}
}