键盘出现时,向上移动表格视图单元格

时间:2016-08-31 09:11:19

标签: xamarin xamarin.ios

当键盘屏幕出现在屏幕上时,如何移动表格单元格。

提前致谢。

2 个答案:

答案 0 :(得分:0)

Check this answer from Xamarin Forums

Push view up on Keyboard active

答案 1 :(得分:0)

这是代码的和平;我在我的申请中使用。可能它可以帮助你。

/*
 Function: Registers current class for receiving notification from keyboard
 */
        void registerNotification(CGRect bounds)
        {
            NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, keyboardWillShow);
            NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, keyboardDidShow);
            NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, keyboardWillHide);
        }
        void keyboardDidShow(NSNotification notification)
        {


        }
        void keyboardWillShow(NSNotification notification)
        {
            //TODO: find a scenario for this
            CGRect bounds = UIKeyboard.BoundsFromNotification(notification);
            moveView(bounds, notification);
        }
        void keyboardWillHide(NSNotification notification)
        {
            CGRect bounds = UIKeyboard.BoundsFromNotification(notification);
            moveView(bounds, notification);
        }
        /*
        Function: Generic function to move the view along with the keyboard 
        */
        void moveView(CGRect bounds, NSNotification notification)
        {
            UIView.BeginAnimations(string.Empty, System.IntPtr.Zero);
            UIView.SetAnimationDuration(0.3);
            //Your code to Move View
            SetNeedsDisplay();
            UIView.CommitAnimations();
        }