예제 #1
0
        private void KeyBoardUpNotification(NSNotification notification)
        {
            propertiesLabel.Hidden = true;
            closeButton.Hidden     = true;
            // get the keyboard size
            var r = UIKeyboard.BoundsFromNotification(notification);

            // Find what opened the keyboard
            foreach (UIView view in this.contentView.Subviews)
            {
                if (view.IsFirstResponder)
                {
                    activeview = view;
                }
            }

            // Bottom of the controller = initial position + height + offset
            bottom = ((float)(activeview.Frame.Y + activeview.Frame.Height + offset));

            // Calculate how far we need to scroll
            scroll_amount = ((float)(r.Height - (contentView.Frame.Size.Height - bottom)));

            // Perform the scrolling
            if (scroll_amount > 0)
            {
                moveViewUp = true;
                ScrollTheView(moveViewUp);
            }
            else
            {
                moveViewUp = false;
            }
        }
 /// <summary>
 /// resizes the view when the keyboard comes up or goes away, allows our scroll view to work
 /// </summary>
 protected void KeyboardOpenedOrClosed(NSNotification n, string openOrClose)
 {
     // if it's opening
     if (openOrClose == "Open")
     {
         Console.WriteLine("Keyboard opening");
         // declare vars
         RectangleF kbdFrame          = UIKeyboard.BoundsFromNotification(n);
         double     animationDuration = UIKeyboard.AnimationDurationFromNotification(n);
         RectangleF newFrame          = contentViewSize;
         // resize our frame depending on whether the keyboard pops in or out
         newFrame.Height -= kbdFrame.Height;
         // apply the size change
         UIView.BeginAnimations("ResizeForKeyboard");
         UIView.SetAnimationDuration(animationDuration);
         scrlMain.Frame = newFrame;
         UIView.CommitAnimations();
     }
     else                 // if it's closing, resize
                          // declare vars
     {
         double animationDuration = UIKeyboard.AnimationDurationFromNotification(n);
         // apply the size change
         UIView.BeginAnimations("ResizeForKeyboard");
         UIView.SetAnimationDuration(animationDuration);
         scrlMain.Frame = contentViewSize;
         UIView.CommitAnimations();
     }
 }
예제 #3
0
        private void KeyBoardUpNotification(NSNotification notification)
        {
            // get the keyboard size
            CGRect keyboardRect = UIKeyboard.BoundsFromNotification(notification);

            // Find what opened the keyboard
            activeview = GetActiveView(NativeView);

            if (activeview == null)
            {
                return;
            }

            // Bottom of the controller = initial position + height + offset
            var point  = GetAbsolutePoint(activeview);
            var bottom = (float)(point.Y + activeview.Frame.Height + offset);

            // Calculate how far we need to scroll
            var scrollAmount = (float)(keyboardRect.Height - (NativeView.Frame.Size.Height - bottom));

            // Perform the scrolling
            if (scrollAmount > 0)
            {
                _scrollAmount = scrollAmount;
                ScrollTheView(true);
            }

            _keyboardIsShow = true;
        }
예제 #4
0
        private void KeyBoardDownNotification(NSNotification notifi)
        {
            var r      = UIKeyboard.BoundsFromNotification(notifi);
            var screen = UIScreen.MainScreen.Bounds;

            SetElementSize(new Size(r.Width, screen.Height));
        }
예제 #5
0
        private void KeyBoardUpNotification(NSNotification notification)
        {
            // get the keyboard size
            CGRect r = UIKeyboard.BoundsFromNotification(notification);

            // Find what opened the keyboard
            foreach (UIView view in this.View.Subviews)
            {
                if (view.IsFirstResponder)
                {
                    activeview = view;
                }
            }

            if (activeview != null)
            {
                // Bottom of the controller = initial position + height + offset
                bottom = (activeview.Frame.Y + activeview.Frame.Height + offset);
            }

            // Calculate how far we need to scroll
            scroll_amount = (r.Height - (View.Frame.Size.Height - bottom));

            // Perform the scrolling
            if (scroll_amount > 0)
            {
                moveViewUp = true;
                ScrollTheView(moveViewUp);
            }
            else
            {
                moveViewUp = false;
            }
        }
예제 #6
0
        void keyboardWillShow(NSNotification notification)
        {
            //TODO: find a scenario for this
            CGRect bounds = UIKeyboard.BoundsFromNotification(notification);

            moveView(bounds, notification);
        }
        private void KeyboardUpNotification(NSNotification notification)
        {
            ResetTheView();

            RectangleF r = (System.Drawing.RectangleF)UIKeyboard.BoundsFromNotification(notification);


            if (lastEdit != null && lastEdit.IsEditing)
            {
                //Calculate the bottom of the Texbox
                //plus a small margin...
                bottomPoint = ((float)(lastEdit.Frame.Y + lastEdit.Frame.Height + 20));

                //Calculate the amount to scroll the view
                //upwards so the Textbox becomes visible...
                //This is the height of the Keyboard -
                //(the height of the display - the bottom
                //of the Texbox)...
                scrollamount = ((float)(r.Height - (View.Frame.Size.Height - bottomPoint)));
            }

            //Check to see whether the view
            //should be moved up...
            if (scrollamount > 0)
            {
                moveViewUp = true;
                ScrollTheView(moveViewUp);
            }
            else
            {
                moveViewUp = false;
            }
        }
예제 #8
0
        /// <summary>
        /// Keies the board did show.
        /// </summary>
        /// <param name="notification">Notification.</param>
        private void KeyBoardDidShow(NSNotification notification)
        {
            // get the keyboard size
            CoreGraphics.CGRect notificationBounds = UIKeyboard.BoundsFromNotification(notification);

            // Find what opened the keyboard
            foreach (UIView view in this.View.Subviews)
            {
                if (view.IsFirstResponder)
                {
                    activeTextFieldView = view;
                }
            }

            // Bottom of the controller = initial position + height + offset
            bottomOfTheActiveTextField = (activeTextFieldView.Frame.Y + activeTextFieldView.Frame.Height + offsetBetweenKeybordAndTextField);

            // Calculate how far we need to scroll
            amountToScroll = (notificationBounds.Height - (View.Frame.Size.Height - bottomOfTheActiveTextField));

            // Perform the scrolling
            if (amountToScroll > 0)
            {
                bottomOfTheActiveTextField -= alreadyScrolledAmount;
                amountToScroll              = (notificationBounds.Height - (View.Frame.Size.Height - bottomOfTheActiveTextField));
                alreadyScrolledAmount      += amountToScroll;
                isMoveRequired              = true;
                ScrollTheView(isMoveRequired);
            }
            else
            {
                isMoveRequired = false;
            }
        }
예제 #9
0
        void HandleKeyboardDidHide(NSNotification n)
        {
            var size = UIKeyboard.BoundsFromNotification(n).Size;

            UIView.BeginAnimations("kbd");

            var f = textEditor.Frame;

            f.Height        += size.Height;
            textEditor.Frame = f;

            if (textLengthLabel != null)
            {
                f    = textLengthLabel.Frame;
                f.Y += size.Height;
                textLengthLabel.Frame = f;
            }

            if (linksLabel != null)
            {
                f    = linksLabel.Frame;
                f.Y += size.Height;
                linksLabel.Frame = f;
            }

            UIView.CommitAnimations();
        }
        private void OnKeyboardUp(NSNotification notification)
        {
            var r = UIKeyboard.BoundsFromNotification(notification);

            // Find what opened the keyboard
            foreach (var view in this.View.Subviews)
            {
                if (view.IsFirstResponder)
                {
                    _activeview = view;
                }
            }

            if (_activeview != null)
            {
                // Bottom of the controller = initial position + height + offset
                _bottom = ((float)(_activeview.Frame.Y + _activeview.Frame.Height + offset));

                // Calculate how far we need to scroll
                _scrollAmount = ((float)(r.Height - (View.Frame.Size.Height - _bottom)));

                // Perform the scrolling
                if (_scrollAmount > 0)
                {
                    _moveViewUp = true;
                    ScrollTheView(_moveViewUp);
                }
                else
                {
                    _moveViewUp = false;
                }
            }
        }
예제 #11
0
        private void keyboardUpNotification(NSNotification notification)
        {
            //Get the bounds of the keyboard...
            resetView();

            RectangleF r = UIKeyboard.BoundsFromNotification(notification);

            if (inputView != null && inputView.IsEditing)
            {
                //Calculate the bottom of the Texbox
                //plus a small margin...
                bottomPoint = (this.inputView.Frame.Y + this.inputView.Frame.Height + 10);

                //Calculate the amount to scroll the view
                //upwards so the Textbox becomes visible...
                //This is the height of the Keyboard -
                //(the height of the display - the bottom
                //of the Texbox)...
                scrollamount = (r.Height - (View.Frame.Size.Height - bottomPoint));
            }

            //Check to see whether the view
            //should be moved up...
            if (scrollamount > 0)
            {
                moveViewUp = true;
                scroll(moveViewUp);
            }
            else
            {
                moveViewUp = false;
            }
        }
예제 #12
0
    public override void ViewWillAppear(bool animated)
    {
        base.ViewWillAppear(animated);

        obs1 = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, delegate(NSNotification n){
            var kbdRect   = UIKeyboard.BoundsFromNotification(n);
            var duration  = UIKeyboard.AnimationDurationFromNotification(n);
            var frame     = View.Frame;
            frame.Height -= kbdRect.Height;
            UIView.BeginAnimations("ResizeForKeyboard");
            UIView.SetAnimationDuration(duration);
            View.Frame = frame;
            UIView.CommitAnimations();
        });

        obs2 = NSNotificationCenter.DefaultCenter.AddObserver("UIKeyboardWillHideNotification", delegate(NSNotification n){
            var kbdRect   = UIKeyboard.BoundsFromNotification(n);
            var duration  = UIKeyboard.AnimationDurationFromNotification(n);
            var frame     = View.Frame;
            frame.Height += kbdRect.Height;
            UIView.BeginAnimations("ResizeForKeyboard");
            UIView.SetAnimationDuration(duration);
            View.Frame = frame;
            UIView.CommitAnimations();
        });
    }
예제 #13
0
        private void keyboardWillShow(NSNotification notification)
        {
            try
            {
                if (!keyboardPushedUp)
                {
                    //CGPoint point = scrollview.ContentOffset;
                    //point.Y = point.Y + 90;
                    //scrollview.SetContentOffset(point, true);
                    keyboardPushedUp = true;


                    // get the keyboard size
                    RectangleF r = (System.Drawing.RectangleF)UIKeyboard.BoundsFromNotification(notification);

                    //// Find what opened the keyboard
                    //foreach (UIView view in this.View.Subviews)
                    //{
                    //    if (view.IsFirstResponder)
                    //        activeview = view;
                    //}

                    // Bottom of the controller = initial position + height + offset
                    //bottom = (LastNameTxt.Frame.Y + LastNameTxt.Frame.Height + offset);

                    //// Calculate how far we need to scroll
                    //scroll_amount = (r.Height - (View.Frame.Size.Height - bottom));

                    if (UserInterfaceIdiomIsPhone)
                    {
                        scroll_amount = 50;
                    }
                    else
                    {
                        scroll_amount = 80;
                    }

                    // Perform the scrolling
                    if (scroll_amount > 0)
                    {
                        moveViewUp = true;
                        ScrollTheView(moveViewUp);
                    }
                    else
                    {
                        moveViewUp = false;
                    }
                }
            }
            catch (NullReferenceException ex)
            {
                Debug.WriteLine("Null exception :: " + ex.Message);
            }
            catch (Exception ex1)
            {
                Debug.WriteLine("Exception occurred :: " + ex1.Message);
            }
        }
예제 #14
0
 private void DidHideKeyboard(object o, UIKeyboardEventArgs e)
 {
     if (_showKb)
     {
         var keyboardSize = UIKeyboard.BoundsFromNotification(e.Notification);
         _container.Center = new CGPoint(_container.Center.X, _container.Center.Y + keyboardSize.Height / 2);
         _showKb           = !_showKb;
     }
 }
        private void KeyBoardUpNotification(NSNotification notification)
        {
            // get the keyboard size
            CGRect r         = UIKeyboard.BoundsFromNotification(notification);
            CGRect viewFrame = View.Bounds;
            // get new height of the content view
            nfloat currentViewHeight = viewFrame.Height - r.Height;

            // update scrollViewFrame
            Scroll.ContentSize   = new CGSize(UIScreen.MainScreen.Bounds.Width, currentViewHeight);
            Scroll.ContentOffset = new CGPoint(0, 170);
        }
예제 #16
0
        private void KeyBoardUpNotification(NSNotification notification)
        {
            // get the keyboard size
            CGRect r = UIKeyboard.BoundsFromNotification(notification);

            CGRect viewFrame = View.Bounds;

            // get new height of the content view
            nfloat currentViewHeight = viewFrame.Height + r.Height;

            // update scrollViewFrame
            scrl.Frame = new CGRect(scrl.Frame.X, scrl.Frame.Y, scrl.Frame.Width, currentViewHeight);
        }
예제 #17
0
        private void KeyBoardUpNotification(NSNotification notification)
        {
            if (!moveViewUp)
            {
                // get the keyboard size
                CGRect r = UIKeyboard.BoundsFromNotification(notification);

                // Find what opened the keyboard
                foreach (UIView view in this.View.Subviews)
                {
                    if (view.GetType() == typeof(CommentAreaView))
                    {
                        foreach (UIView view2 in view.Subviews)
                        {
                            if (view2.IsFirstResponder)
                            {
                                activeview = view2;
                            }
                        }
                    }
                }

                // Bottom of the controller = initial position + height - View Y position + offset (relative to the screen)
                UIView relativePositionView = UIApplication.SharedApplication.KeyWindow;
                CGRect relativeFrame        = activeview.Superview.ConvertRectToView(activeview.Frame, relativePositionView);

                bottom = (float)((relativeFrame.Y) + relativeFrame.Height - View.Frame.Y + offset);

                // Calculate how far we need to scroll
                scroll_amount = (float)(r.Height - (View.Frame.Size.Height - bottom));

                // Check the necessity of scroll
                var section = (int)feed.NumberOfSections() - 1;
                var item    = (int)feed.NumberOfItemsInSection(section) - 1;
                if (item != -1)
                {
                    NSIndexPath indexPath = NSIndexPath.FromRowSection(item, section);
                    lastCommentBottom = (float)feed.GetLayoutAttributesForItem(indexPath).Frame.Y + (float)feed.GetLayoutAttributesForItem(indexPath).Frame.Height + offset;
                }
                else
                {
                    lastCommentBottom = 0f;
                }

                // Perform the scrolling
                moveViewUp = true;
                ScrollTheView(moveViewUp);
            }
        }
예제 #18
0
        private void KeyBoardUpNotification(NSNotification notification)
        {
            CGRect r = UIKeyboard.BoundsFromNotification(notification);

            scroll_amount = (float)r.Height - ((float)emailView.Frame.Y - (float)emailView.Frame.Size.Height);

            if (scroll_amount > 0)
            {
                moveViewUp = true;
                ScrollTheView(moveViewUp);
            }
            else
            {
                moveViewUp = false;
            }
        }
        //========================================================================

        //========================================================================
        /// <summary>
        /// resizes the view when the keyboard comes up or goes away, allows our scroll view to work
        /// </summary>
        protected void KeyboardOpenedOrClosed(NSNotification n, string openOrClose)
        {
            //---- if it's opening
            if (openOrClose == "Open")
            {
                Console.WriteLine("Keyboard opening");

                //---- if it's actually been closed, resize
                if (this._keyboardClosed)
                {
                    //---- declare vars
                    RectangleF kbdFrame          = UIKeyboard.BoundsFromNotification(n);
                    double     animationDuration = UIKeyboard.AnimationDurationFromNotification(n);
                    RectangleF mainViewFrame     = this.View.Frame;

                    //---- resize our frame depending on whether the keyboard pops in or out
                    mainViewFrame.Height -= kbdFrame.Height;

                    //---- apply the size change
                    UIView.BeginAnimations("ResizeForKeyboard");
                    UIView.SetAnimationDuration(animationDuration);
                    this.View.Frame = mainViewFrame;
                    UIView.CommitAnimations();

                    //---- track our keyboard variable
                    this._keyboardClosed = false;
                }
            }
            else             //---- if it's closing, resize
            {
                //---- declare vars
                RectangleF kbdFrame          = UIKeyboard.BoundsFromNotification(n);
                double     animationDuration = UIKeyboard.AnimationDurationFromNotification(n);
                RectangleF mainViewFrame     = this.View.Frame;
                mainViewFrame.Height += kbdFrame.Height;

                //---- apply the size change
                UIView.BeginAnimations("ResizeForKeyboard");
                UIView.SetAnimationDuration(animationDuration);
                this.View.Frame = mainViewFrame;
                UIView.CommitAnimations();

                //---- track our keyboard variable
                this._keyboardClosed = true;
            }
        }
예제 #20
0
        private void KeyBoardUpNotification(NSNotification notification)
        {
            _activeview = ScrollViewTopHelper.GetActiveView(View);

            CGRect keyBourdSize = UIKeyboard.BoundsFromNotification(notification);

            _scrollAmount = ScrollViewTopHelper.GetScrollAmount(_activeview, keyBourdSize);

            if (_scrollAmount <= default(float))
            {
                _isMoveViewUp = false;
                return;
            }

            _isMoveViewUp = true;

            ScrollTheView(_isMoveViewUp);
        }
        void KeyBoardUpNotification(NSNotification notification)
        {
            //if (!txtEmail.IsEditing && !txtPassword.IsEditing)
            //return;

            CGRect r = UIKeyboard.BoundsFromNotification(notification);

            scroll_amount = (float)r.Height / 2;

            if (scroll_amount > 0)
            {
                moveViewUp = true;
                ScrollTheView(moveViewUp);
            }
            else
            {
                moveViewUp = false;
            }
        }
        private void KeyBoardUpNotification(NSNotification notification)
        {
            if (!txtComment.IsFirstResponder)
            {
                return;
            }

            CGRect r = UIKeyboard.BoundsFromNotification(notification);

            scroll_amount = (float)r.Height / 1.5f;

            if (scroll_amount > 0)
            {
                moveViewUp = true;
                ScrollTheView(moveViewUp);
            }
            else
            {
                moveViewUp = false;
            }
        }
예제 #23
0
        /// <summary>
        /// Keies the board up notification.
        /// </summary>
        /// <param name="notification">Notification.</param>
        private void KeyBoardUpNotification(NSNotification notification)
        {
            // get the keyboard size

            /*NSValue val = new NSValue(notification.UserInfo.ValueForKey(UIKeyboard.FrameBeginUserInfoKey).Handle);
             * RectangleF r = val.RectangleFValue;*/
            CGRect r = UIKeyboard.BoundsFromNotification(notification);

            // Find what opened the keyboard
            foreach (UIView view in blocksOnView)
            {
                foreach (UIView inView in view.Subviews)
                {
                    if (inView.IsFirstResponder)
                    {
                        activeview = view;
                    }
                }
            }
            if (activeview != null)
            {
                // Bottom of the controller = initial position + height + offset
                bottom = ((float)activeview.Frame.Y +
                          (float)activeview.Frame.Height + offsetKeyboard);

                // Calculate how far we need to scroll
                scrollamount = ((float)r.Height - (float)(View.Frame.Size.Height - bottom));

                // Perform the scrolling
                if (scrollamount > 0)
                {
                    moveViewUp = true;
                    ScrollTheView(moveViewUp);
                }
                else
                {
                    moveViewUp = false;
                }
            }
        }
예제 #24
0
        void HandleKeyboardDidShow(NSNotification n)
        {
            var size = UIKeyboard.BoundsFromNotification(n).Size;

            var f = textEditor.Frame;

            f.Height        -= size.Height;
            textEditor.Frame = f;

            if (textLengthLabel != null)
            {
                f    = textLengthLabel.Frame;
                f.Y -= size.Height;
                textLengthLabel.Frame = f;
            }

            if (linksLabel != null)
            {
                f    = linksLabel.Frame;
                f.Y -= size.Height;
                linksLabel.Frame = f;
            }
        }
예제 #25
0
        private void KeyBoardUpNotification(NSNotification notification)
        {
            if (!moveViewUp)
            {
                // get the keyboard size
                CGRect r = UIKeyboard.BoundsFromNotification(notification);

                // Find what opened the keyboard
                foreach (UIView view in this.View.Subviews)
                {
                    if (view.IsFirstResponder)
                    {
                        activeview = view;
                    }
                }

                if (activeview != null)
                {
                    // Bottom of the controller = initial position + height - View Y position + offset (relative to the screen)
                    UIView relativePositionView = UIApplication.SharedApplication.KeyWindow;
                    CGRect relativeFrame        = activeview.Superview.ConvertRectToView(activeview.Frame, relativePositionView);

                    bottom = (float)((relativeFrame.Y) + relativeFrame.Height - View.Frame.Y + offset);

                    // Calculate how far we need to scroll
                    scroll_amount = (float)(r.Height - (View.Frame.Size.Height - bottom));
                }
                else
                {
                    scroll_amount = 0;
                }

                // Perform the scrolling
                moveViewUp = true;
                ScrollTheView(moveViewUp);
            }
        }
        /// <summary>
        /// resizes the view when the keyboard comes up or goes away, allows our scroll view to work
        /// </summary>
        protected void KeyboardOpenedOrClosed(NSNotification n, string openOrClose)
        {
            //---- if it's opening
            if (openOrClose == "Open")
            {
                Console.WriteLine("Keyboard opening");

                //---- declare vars
                RectangleF kbdFrame          = UIKeyboard.BoundsFromNotification(n);
                double     animationDuration = UIKeyboard.AnimationDurationFromNotification(n);

                //---- get the current view's bounds
                RectangleF newFrame = this.View.Bounds;
                //---- shrink the frame's height
                newFrame.Height -= kbdFrame.Height;

                //---- apply the size change
                UIView.BeginAnimations("ResizeForKeyboard");
                UIView.SetAnimationDuration(animationDuration);
                this.scrlMain.Frame = newFrame;
                UIView.CommitAnimations();
            }
            else             //---- if it's closing, resize
            {
                //---- declare vars
                double animationDuration = UIKeyboard.AnimationDurationFromNotification(n);

                Console.WriteLine("resetting scroll view frame to: " + this._contentViewSize.ToString());

                //---- reset the content size back to what it was before
                UIView.BeginAnimations("ResizeForKeyboard");
                UIView.SetAnimationDuration(animationDuration);
                this.scrlMain.Frame = this._contentViewSize;
                UIView.CommitAnimations();
            }
        }
예제 #27
0
        private void KeyBoardUpNotification(NSNotification notifi)
        {
            _keyboardBounds = UIKeyboard.BoundsFromNotification(notifi);

            ViewDidLayoutSubviews();
        }
        private void KeyboardUpNotification(NSNotification notification)
        {
            var keyboardFrame = UIKeyboard.BoundsFromNotification(notification);

            entryEffect.OnKeyboardRectChanged(new Rect(keyboardFrame.X, keyboardFrame.Y, keyboardFrame.Width, keyboardFrame.Height));
        }
예제 #29
0
        private void KeyBoardUpNotification(NSNotification notifi)
        {
            _keyboardBounds = UIKeyboard.BoundsFromNotification(notifi);

            UpdateElementSize();
        }
 void HandleKeyboardState(NSNotification notification)
 {
     keyboardBounds = UIKeyboard.BoundsFromNotification(notification);
     View.Center    = new CGPoint(View.Bounds.GetMidX(), View.Bounds.GetMidY() - keyboardBounds.Height);
     SetViewMovedUp(!keyboardBounds.IsEmpty);
 }