Simple animation to increase Height of a View

JOAOSerraJOAOSerra PTMember ✭✭
edited January 2018 in Xamarin.iOS

Hi,
Im trying to do a simple animation to increase the height of a View (vwId).
I notice i need to work with the y scale but I don't seem to have any reaction on the view.

Any idea what i might be missing? I've left commented the code that i've already tried.

    private void ShowDocumentName()
    {
    // vwId.TranslatesAutoresizingMaskIntoConstraints = false;
        Action raiseHeight = () => {
            //vwId.Frame = new CGRect(vwId.Frame.X, vwId.Frame.Y, vwId.Frame.Width, vwId.Frame.Height + 50);
            //vwId.Transform.Scale(1,1+newScale);
            vwId.Transform = CGAffineTransform.MakeScale(1, 2 + newScale);

            lblDocument.Hidden = false;
            imgUploadOk.Hidden = false;

            View.SetNeedsDisplay();
            View.LayoutIfNeeded();
        };

        UIView.Animate(4,0, UIViewAnimationOptions.CurveLinear,raiseHeight,null);

    //UIViewPropertyAnimator propertyAnimator = new UIViewPropertyAnimator(4, UIViewAnimationCurve.Linear, raiseHeight);
        //propertyAnimator.StartAnimation();
     }

Thank you in advance.

-- EDIT --

Turns out that the problem is not the code. But since I open a modal it wont animate on document selection after closing the modal . How to solve this?

    pickerMenu.DidPickDocumentAtUrls += PickerMenu_DidPickDocumentAtUrls;

    void PickerMenu_DidPickDocumentAtUrls(object sender, UIDocumentPickedAtUrlsEventArgs e)
    {
        ShowDocumentName(e.Urls[0].LastPathComponent);
    }

    btnUploadDocument.AddGestureRecognizer(new UITapGestureRecognizer((obj) => {
            this.PresentViewController(pickerMenu, false, null);
        }));

Best Answer

  • JOAOSerraJOAOSerra PT ✭✭
    edited January 2018 Accepted Answer

    Turns out that it was passing twice in viewdidload and viewdidappear, probably meaning it was a different instance.

    I had to change the
    pickerMenu.ModalPresentationStyle = UIModalPresentationStyle.PopOver;

    to
    pickerMenu.ModalPresentationStyle = UIModalPresentationStyle.Custom;

    why? i have no idea... but it works now

Answers

  • JOAOSerraJOAOSerra PTMember ✭✭
    edited January 2018 Accepted Answer

    Turns out that it was passing twice in viewdidload and viewdidappear, probably meaning it was a different instance.

    I had to change the
    pickerMenu.ModalPresentationStyle = UIModalPresentationStyle.PopOver;

    to
    pickerMenu.ModalPresentationStyle = UIModalPresentationStyle.Custom;

    why? i have no idea... but it works now

Sign In or Register to comment.