【问题标题】:Scrollview of whole page is not working when I added Tap to zoom view(Image) functionality in xamarin iOS当我在 xamarin iOS 中添加点击缩放视图(图像)功能时,整个页面的滚动视图不起作用
【发布时间】:2016-11-28 18:32:20
【问题描述】:

当我在 xamarin iOS 中添加点击缩放视图(图像)功能时,整个页面的滚动视图不起作用。

我有两个滚动视图-一个用于点击缩放功能,另一个滚动滚动2用于滚动整个详细信息页面。这个滚动2不工作,但点击缩放工作正常。

【问题讨论】:

  • 您能否为问题添加更多详细信息?可能是共享代码sn-p
  • 我在答案框中分享了我的代码 sn-p

标签: ios xamarin xamarin.ios


【解决方案1】:
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) .重试(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; 如果(scrollView.ZoomScale > 1) scrollView.SetZoomScale(0.25f, true); 别的 scrollView.SetZoomScale(3f, true); }

scroll2 是整个页面的滚动,scrollview 是放大时的图像视图滚动

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-07
    • 2016-07-07
    相关资源
    最近更新 更多