Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

NSScrollView not working

$
0
0

I have taken a scrollview(added using IB), I am adding a new view on every button click.The issue is view inside scrollview doesn't get scrolled. Do we programmatically have to do something to make it scroll??..
What am I missing??
Following are the code snippets:-

Adjusting the layout of the View


        public void layout()
    {
        NSView[] subviews = simpleview.Subviews;
        PointF curPoint;
        curPoint = new PointF(simpleview.Bounds.Size.Width / 2.0f, 0.0f);
        foreach (NSView subview in subviews) 
        {
            RectangleF frame = new RectangleF (curPoint.X - 453.0f / 2.0f, curPoint.Y, 453.0f, 60.0f);
            animateView (subview, frame);
            curPoint.Y += frame.Size.Height + SEPARATION;
        }

    }

       private RectangleF integralRect (RectangleF rect) 
    {
        return simpleview.ConvertRectFromBase(simpleview.ConvertRectToBase(rect));  
    }

                private void animateView(NSView subView, RectangleF toFrame) 
    {
        #if true
        // Simple animation: assign the new value, and let CoreAnimation
        // take it from here

        ((NSView) subView.Animator).Frame = toFrame;
        #else
        //
        // Performing the animation by hand, every step of the way
        //
        var animationY = CABasicAnimation.FromKeyPath("position.y");
        animationY.To = NSNumber.FromFloat(toFrame.Y);
        animationY.AnimationStopped += delegate {
        //Console.WriteLine("animation stopped");
        subView.Layer.Frame = toFrame;
        };

        var animationX = CABasicAnimation.FromKeyPath("position.x");
        animationX.To = NSNumber.FromFloat(toFrame.X);

        animationY.AutoReverses = false;
        animationX.AutoReverses = false;

        animationY.RemovedOnCompletion = false;
        animationX.RemovedOnCompletion = false;

        animationY.FillMode = CAFillMode.Forwards;
        animationX.FillMode = CAFillMode.Forwards;

        subView.Layer.AddAnimation(animationX,"moveX");
        subView.Layer.AddAnimation(animationY,"moveY");
        #endif
    }

Adding a new view on buttonclick

      partial void Addbutton (NSObject sender)
    {
        simpleview.AddSubview(new UserControlController().View);
        layout();
    }

Basically my view is not getting drawn and my scrollbars are not enabled too.

Note: The above code is based on AnimatingViews from xamarin mac samples.
Thanks in advance!


Viewing all articles
Browse latest Browse all 204402

Trending Articles