void ClearCloserRecognizer(ContextActionsCell cell)
        {
            if (_globalCloser == null || _globalCloser.State == UIGestureRecognizerState.Cancelled)
            {
                return;
            }

            cell?.ContentCell?.RemoveGestureRecognizer(_closer);
            _closer.Dispose();
            _closer = null;

            _table.RemoveGestureRecognizer(_globalCloser);
            _table = null;
            _globalCloser.Dispose();
            _globalCloser = null;
        }
        void ClearCloserRecognizer(UIScrollView scrollView)
        {
            if (_globalCloser == null || _globalCloser.State == UIGestureRecognizerState.Cancelled)
            {
                return;
            }

            var cell = GetContextCell(scrollView);

            cell.ContentCell.RemoveGestureRecognizer(_closer);
            _closer.Dispose();
            _closer = null;

            _table.RemoveGestureRecognizer(_globalCloser);
            _table = null;
            _globalCloser.Dispose();
            _globalCloser = null;
        }
        public override void WillEndDragging(UIScrollView scrollView, PointF velocity, ref PointF targetContentOffset)
        {
            if (ShouldIgnoreScrolling(scrollView))
            {
                return;
            }

            var width            = ButtonsWidth;
            var x                = targetContentOffset.X;
            var parentThreshold  = scrollView.Frame.Width * .4f;
            var contentThreshold = width * .8f;

            if (x >= parentThreshold || x >= contentThreshold)
            {
                IsOpen = true;
                targetContentOffset = new PointF(width, 0);
                RemoveHighlight(scrollView);

                if (_globalCloser == null)
                {
                    UIView view = scrollView;
                    while (view.Superview != null)
                    {
                        view = view.Superview;

                        NSAction close = () =>
                        {
                            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                            {
                                RestoreHighlight(scrollView);
                            }

                            IsOpen = false;
                            scrollView.SetContentOffset(new PointF(0, 0), true);

                            ClearCloserRecognizer(scrollView);
                        };

                        var table = view as UITableView;
                        if (table != null)
                        {
                            _table        = table;
                            _globalCloser = new GlobalCloseContextGestureRecognizer(scrollView, close);
                            _globalCloser.ShouldRecognizeSimultaneously = (recognizer, r) => r == _table.PanGestureRecognizer;
                            table.AddGestureRecognizer(_globalCloser);

                            _closer = new UITapGestureRecognizer(close);
                            var cell = GetContextCell(scrollView);
                            cell.ContentCell.AddGestureRecognizer(_closer);
                        }
                    }
                }
            }
            else
            {
                ClearCloserRecognizer(scrollView);

                IsOpen = false;
                targetContentOffset = new PointF(0, 0);

                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    RestoreHighlight(scrollView);
                }
            }
        }