Exemplo n.º 1
0
        private void centerScrollViewContents()
        {
            SizeF      boundsSize    = oParentController.scrollView.Bounds.Size;
            RectangleF contentsFrame = oParentController.containerView.Frame;
            var        contentW      = oParentController.scrollView.ContentSize.Width;


            //if (contentsFrame.Size.Width < boundsSize.Width) {
            //	contentsFrame.X = (boundsSize.Width - contentsFrame.Size.Width) / 2.0f;
            //} else {
            //contentsFrame.X = 0.0f;
            //}
            Console.WriteLine("contentsFrame {0} boundsSize {1}", contentsFrame, boundsSize);

            //contentsFrame.Size.Width = oParentController.Frame.Width;
            //contentsFrame.X = 0.0f;
            if (contentsFrame.Size.Height < boundsSize.Height)
            {
                contentsFrame.Y = (boundsSize.Height - contentsFrame.Size.Height) / 2.0f;
            }
            else
            {
                contentsFrame.Y = 0.0f;
            }
            contentsFrame.Width = oParentController.Bounds.Width;
            Console.WriteLine("frame width {0} frame position {1}", oParentController.Frame.Width, contentsFrame.Y);
            oParentController.containerView.Frame = contentsFrame;

            oParentController.SetContentXOffset(myScrollViewOffset.X, false);

            Console.WriteLine("Scrolloffset {0} {1}", myScrollViewOffset, oParentController.scrollView.ContentOffset);
        }