C# 单击图像始终显示完整视图Xamarin IOS中的最后一张图像

C# 单击图像始终显示完整视图Xamarin IOS中的最后一张图像,c#,xamarin.ios,xamarin,C#,Xamarin.ios,Xamarin,在tableview单元格中,如果有更多图像,我将动态显示一些消息和图像 在水平滚动中显示。现在我的任务是单击特定的图像,需要在完整的页面视图中显示该图像,我已经完成了代码,但我的问题是单击在完整视图中显示最后一个图像的任何图像 谁能帮帮我吗 if (contents.Count > 0) { _scrollView = new UIScrollView (){Tag = 1002}; //_image = n

在tableview单元格中,如果有更多图像,我将动态显示一些消息和图像 在水平滚动中显示。现在我的任务是单击特定的图像,需要在完整的页面视图中显示该图像,我已经完成了代码,但我的问题是单击在完整视图中显示最后一个图像的任何图像

谁能帮帮我吗

        if (contents.Count > 0)
        {
            _scrollView = new UIScrollView (){Tag = 1002};
            //_image = new UIImageView (UIImage.FromBundle("placeholder.png"));
            _scrollView.Frame = new RectangleF (0, rowHeight, 320, 300);    
            _scrollView.PagingEnabled = true;
            _scrollView.Bounces = true;
            _scrollView.DelaysContentTouches = true;
            _scrollView.ShowsHorizontalScrollIndicator = true;
            //_scrollView.ScrollRectToVisible (new RectangleF (320, 0, 320, 480), true);
            ContentView.Add(_scrollView);
            int x = 35;
            bool setRowHeight = true;
            int scrollwidth = 0;

            foreach (var contentItem in contents)
            {

                if (contentItem.FilePath.Length != 0)
                {
                    index++;
                    //_image.SetImage (new NSUrl (contentItem.FilePath), UIImage.FromBundle ("placeholder.png"));
                    //_image.Tag = 1001;
                    _image = new UIImageView(FromUrl(contentItem.FilePath)) { Tag = 1001 };

                    _imagePath = contentItem.FilePath;
                    _image.Frame = new RectangleF(x, 0, 250, _image.Image.CGImage.Height);
                    x = x + (Convert.ToInt32( Bounds.Width));
                    scrollwidth = scrollwidth + Convert.ToInt32( Bounds.Width);
                    _scrollView.ContentSize = new SizeF (scrollwidth,150);
                    _scrollView.Add (_image);                   

                    if (setRowHeight) {
                        rowHeight += _image.Image.CGImage.Height + 10;
                        setRowHeight = false;
                    }

                    // ================
                    var doubletap = new UITapGestureRecognizer();
                    doubletap.NumberOfTapsRequired = 1; // single tap
                    doubletap.AddTarget(this, new MonoTouch.ObjCRuntime.Selector("DoubleTapSelector"));
                    _image.AddGestureRecognizer(doubletap); // detect when the scrollView is tapped
                    _image.UserInteractionEnabled = true;

                    // =================
                }
            }

        }


    [MonoTouch.Foundation.Export("DoubleTapSelector")]
    public void OnDoubleTap(UIGestureRecognizer sender)
    {
        FullImageViewControler fullImageViewController = new FullImageViewControler(_imagePath);
        UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(fullImageViewController, true, null);
    }

是的-
OnDoubleTap
始终使用最新版本的
\u imagePath
,这将是您设置它的最后一个值。您需要为每个点击处理程序指定一个不同的代理,或者您需要找到某种方法来查找单击的图像,并从中计算出完整的图像路径。是的,确切地说,您可以为我提供任何代理处理程序。不是立即-考虑到
选择器
的工作方式,我需要检查一下什么是最合适的解决方案。我今晚也许可以看看这样做……你不需要使用选择器。
UITapGestureRecognitor
具有接受委托的重载。然后您可以捕获当前图像路径并使用它。