예제 #1
0
        public SWTableViewCell(UITableViewCellStyle style, string reuseIdentifier,
                               UITableView containingTable, IEnumerable <UIButton> rightUtilityButtons,
                               UIView leftView, List <UIView> mainView)
            : base(style, reuseIdentifier)
        {
            scrollViewLeft            = leftView;
            this.rightUtilityButtons  = rightUtilityButtons.ToArray();
            scrollViewButtonViewRight = new SWUtilityButtonView(this.rightUtilityButtons, this);

            containingTableView = containingTable;
            height             = (float)containingTableView.RowHeight;
            scrollViewDelegate = new SWScrollViewDelegate(this);


            // Check if the UITableView will display Indices on the right. If that's the case, add a padding
            if (containingTableView.RespondsToSelector(new Selector("sectionIndexTitlesForTableView:")))
            {
                string[] indices = containingTableView.Source.SectionIndexTitles(containingTableView);
                additionalRightPadding = indices == null || indices.Length == 0 ? 0 : SectionIndexWidth;
            }

            // Set up scroll view that will host our cell content
            cellScrollView               = new UIScrollView(new RectangleF(0, 0, (float)Bounds.Width, height));
            cellScrollView.ContentSize   = new SizeF((float)Bounds.Width + UtilityButtonsPadding, height);
            cellScrollView.ContentOffset = ScrollViewContentOffset;
            cellScrollView.Delegate      = scrollViewDelegate;
            cellScrollView.ShowsHorizontalScrollIndicator = false;
            cellScrollView.ScrollsToTop = false;
            var tapGestureRecognizer = new UITapGestureRecognizer(OnScrollViewPressed);

            cellScrollView.AddGestureRecognizer(tapGestureRecognizer);

            // Set up the views that will hold the utility buttons
            scrollViewLeft.Frame = new RectangleF(ScrollLeftViewWidth, 0, ScrollLeftViewWidth, height);
            cellScrollView.AddSubview(scrollViewLeft);

            scrollViewButtonViewRight.Frame = new RectangleF((float)Bounds.Width, 0, RightUtilityButtonsWidth, height);

            cellScrollView.AddSubview(scrollViewButtonViewRight);


            // Populate the button views with utility buttons
            scrollViewButtonViewRight.PopulateUtilityButtons();
            // Create the content view that will live in our scroll view
            scrollViewContentView = new UIView(new RectangleF(ScrollLeftViewWidth, 0, (float)Bounds.Width, height));
            cellScrollView.AddSubview(scrollViewContentView);
            this.mainView = mainView;
            BuildMainView();

            AddSubview(cellScrollView);
            HideSwipedContent(false);
        }
        public void constructSWTableViewCell(
            IEnumerable <UIButton> rightUtilityButtons,
            UIView leftView, UIView content = null)
        {
            this.scrollViewLeft            = leftView;
            this.rightUtilityButtons       = rightUtilityButtons.ToArray();
            this.scrollViewButtonViewRight = new SWUtilityButtonView(this.rightUtilityButtons, this);


            // Set up scroll view that will host our cell content
            this.cellScrollView               = new UIScrollView(new RectangleF(0, 0, Bounds.Width, height)); //TODO:frames
            this.cellScrollView.ContentSize   = new SizeF(Bounds.Width + this.UtilityButtonsPadding, height); //TODO:frames
            this.cellScrollView.ContentOffset = ScrollViewContentOffset;
            this.cellScrollView.Delegate      = this.scrollViewDelegate;
            this.cellScrollView.ShowsHorizontalScrollIndicator = false;
            this.cellScrollView.ScrollsToTop = false;
            UITapGestureRecognizer tapGestureRecognizer = new UITapGestureRecognizer(OnScrollViewPressed);

            this.cellScrollView.AddGestureRecognizer(tapGestureRecognizer);

            // Set up the views that will hold the utility buttons
            this.scrollViewLeft.Frame = new RectangleF(ScrollLeftViewWidth, 0, ScrollLeftViewWidth, height);//TODO:frame
            this.cellScrollView.AddSubview(scrollViewLeft);

            this.scrollViewButtonViewRight.Frame = new RectangleF(Bounds.Width, 0, RightUtilityButtonsWidth, height);              //TODO:frame
            this.cellScrollView.AddSubview(scrollViewButtonViewRight);



            // Populate the button views with utility buttons
            this.scrollViewButtonViewRight.PopulateUtilityButtons();
            // Create the content view that will live in our scroll view
            this.scrollViewContentView = new UIView(new RectangleF(ScrollLeftViewWidth, 0, Bounds.Width, height));
            this.scrollViewContentView.BackgroundColor = UIColor.White;
            this.cellScrollView.AddSubview(this.scrollViewContentView);
            this.cellScrollView.BringSubviewToFront(this.scrollViewContentView);

            // Add the cell scroll view to the cell
            var contentViewParent = Subviews[0];

            foreach (var subView in contentViewParent.Subviews)
            {
                this.scrollViewContentView.AddSubview(subView);
                subView.BackgroundColor = UIColor.White;
            }
            AddSubview(this.cellScrollView);

            HideSwipedContent(false);
        }
        public SWTableViewCell(UITableViewCellStyle style, string reuseIdentifier,
            UITableView containingTable, IEnumerable<UIButton> rightUtilityButtons,
            UIView leftView, List<UIView> mainView)
            : base(style, reuseIdentifier)
        {
            scrollViewLeft = leftView;
            this.rightUtilityButtons = rightUtilityButtons.ToArray();
            scrollViewButtonViewRight = new SWUtilityButtonView(this.rightUtilityButtons, this);

            containingTableView = containingTable;
            height = (float)containingTableView.RowHeight;
            scrollViewDelegate = new SWScrollViewDelegate(this);

            // Check if the UITableView will display Indices on the right. If that's the case, add a padding
            if (containingTableView.RespondsToSelector(new Selector("sectionIndexTitlesForTableView:"))) {
                string[] indices = containingTableView.Source.SectionIndexTitles(containingTableView);
                additionalRightPadding = indices == null || indices.Length == 0 ? 0 : SectionIndexWidth;
            }

            // Set up scroll view that will host our cell content
            cellScrollView = new UIScrollView(new RectangleF(0, 0, (float)Bounds.Width, height));
            cellScrollView.ContentSize = new SizeF((float)Bounds.Width + UtilityButtonsPadding, height);
            cellScrollView.ContentOffset = ScrollViewContentOffset;
            cellScrollView.Delegate = scrollViewDelegate;
            cellScrollView.ShowsHorizontalScrollIndicator = false;
            cellScrollView.ScrollsToTop = false;
            var tapGestureRecognizer = new UITapGestureRecognizer(OnScrollViewPressed);
            cellScrollView.AddGestureRecognizer(tapGestureRecognizer);

            // Set up the views that will hold the utility buttons
            scrollViewLeft.Frame = new RectangleF(ScrollLeftViewWidth, 0, ScrollLeftViewWidth, height);
            cellScrollView.AddSubview(scrollViewLeft);

            scrollViewButtonViewRight.Frame = new RectangleF((float)Bounds.Width, 0, RightUtilityButtonsWidth, height);

            cellScrollView.AddSubview(scrollViewButtonViewRight);

            // Populate the button views with utility buttons
            scrollViewButtonViewRight.PopulateUtilityButtons();
            // Create the content view that will live in our scroll view
            scrollViewContentView = new UIView(new RectangleF(ScrollLeftViewWidth, 0, (float)Bounds.Width, height));
            cellScrollView.AddSubview(scrollViewContentView);
            this.mainView = mainView;
            BuildMainView();

            AddSubview(cellScrollView);
            HideSwipedContent(false);
        }
        public SWTableViewCell(UITableViewCellStyle style, string reuseIdentifier, 
		                        UITableView containingTable, IEnumerable<UIButton> rightUtilityButtons, 
		                        UIView leftView)
            : base(style, reuseIdentifier)
        {
            this.scrollViewLeft = leftView;
            this.rightUtilityButtons = rightUtilityButtons.ToArray();
            this.scrollViewButtonViewRight = new SWUtilityButtonView (this.rightUtilityButtons, this);

            this.containingTableView = containingTable;
            this.height = containingTableView.RowHeight;
            this.scrollViewDelegate = new SWScrollViewDelegate (this);

            // Check if the UITableView will display Indices on the right. If that's the case, add a padding
            if(containingTableView.RespondsToSelector(new MonoTouch.ObjCRuntime.Selector("sectionIndexTitlesForTableView:")))
            {
                var indices = containingTableView.Source.SectionIndexTitles (containingTableView);
                additionalRightPadding = indices == null || indices.Length == 0 ? 0 : SectionIndexWidth;
            }

            // Set up scroll view that will host our cell content
            this.cellScrollView = new UIScrollView (new RectangleF (0, 0, Bounds.Width, height)); //TODO:frames
            this.cellScrollView.ContentSize = new SizeF (Bounds.Width + this.UtilityButtonsPadding, height);//TODO:frames
            this.cellScrollView.ContentOffset = ScrollViewContentOffset;
            this.cellScrollView.Delegate = this.scrollViewDelegate;
            this.cellScrollView.ShowsHorizontalScrollIndicator = false;
            this.cellScrollView.ScrollsToTop = false;
            UITapGestureRecognizer tapGestureRecognizer = new UITapGestureRecognizer(OnScrollViewPressed);
            this.cellScrollView.AddGestureRecognizer (tapGestureRecognizer);

            // Set up the views that will hold the utility buttons
            this.scrollViewLeft.Frame = new RectangleF (ScrollLeftViewWidth, 0, ScrollLeftViewWidth, height);//TODO:frame
            this.cellScrollView.AddSubview (scrollViewLeft);

            this.scrollViewButtonViewRight.Frame = new RectangleF (Bounds.Width, 0, RightUtilityButtonsWidth, height); //TODO:frame
            this.cellScrollView.AddSubview (scrollViewButtonViewRight);

            // Populate the button views with utility buttons
            this.scrollViewButtonViewRight.PopulateUtilityButtons ();
            // Create the content view that will live in our scroll view
            this.scrollViewContentView = new UIView(new RectangleF(ScrollLeftViewWidth, 0, Bounds.Width, height));
            this.scrollViewContentView.BackgroundColor = UIColor.White;
            this.cellScrollView.AddSubview (this.scrollViewContentView);

            UIView contentViewParent;
            //deals with an internal change introduced in iOS 8
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)){
                contentViewParent = this;
            }
            else {
                // Add the cell scroll view to the cell
                contentViewParent = Subviews[0];
            }

            foreach (var subView in contentViewParent.Subviews) {
                this.scrollViewContentView.AddSubview (subView);
            }
            AddSubview (this.cellScrollView);

            HideSwipedContent (false);
        }