当我在xamarin iOS中添加Tap to zoom view(Image)功能时,整页的Scrollview无效。
我有两个scrollview-one用于点击缩放功能,另一个用于滚动整个详细信息页面的scroll-scroll2。这个scrooll2不工作但Tap to Zoom工作正常。
答案 0 :(得分:0)
scrollView = new UIScrollView(
new CGRect(0, 80,View.Frame.Width
, View.Frame.Height -200));
View.AddSubview(scrollView);
scroll2.ScrollEnabled = true;
scroll2.ContentSize = new CGSize(0f, 1760f);
scrollView.ScrollEnabled = false;
ImageService.Instance.LoadUrl(GlobalVar.imgpath + travelerlistdetail.orderDetails.product_image) .Retry(3,200) .DownSample(100,100) .Into(ImgProd);
//scrollView.ContentSize = ImgProd.Size;
scrollView.AddSubview(ImgProd);
scrollView.MinimumZoomScale = 0.9f;
scrollView.MaximumZoomScale = 3f;
//scrollView.PinchGestureRecognizer.Enabled = false;
//await Task.Delay(2000);
//scrollView.ContentSize = ImgProd.Image.Size;
scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return ImgProd; };
UITapGestureRecognizer doubletap = new UITapGestureRecognizer(OnDoubleTap)
{
NumberOfTapsRequired = 1 // double tap
};
scrollView.AddGestureRecognizer(doubletap);
private void OnDoubleTap(UIGestureRecognizer手势) { scroll2.ScrollEnabled = false; scrollView.ScrollEnabled = true; if(scrollView.ZoomScale> 1) scrollView.SetZoomScale(0.25f,true); 其他 scrollView.SetZoomScale(3f,true); }
scroll2是总页面的滚动,而scrollview是放大时的imageview滚动