Keyboard display issues

I have an older Xamarin iOS app that is running into issues displaying the keyboard when using Modal style views. Details as follows:

  • Running in Simulator, iPad Air 2, iOS 12.1, Landscape mode
  • Using the scroll view approach to prevent the keyboard from hiding fields
  • We didn't have this issue up through iOS 11, just seems to have introduced itself with iOS 12.
  • Code as follows

        private const float _keyboardHeight = 320f;
        private bool _isKeyboardUp = false;
    
        NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillShowNotification, KeyboardUpNotification);
        NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification, KeyBoardDownNotification);
    
        private void KeyboardUpNotification (NSNotification notification)
        {
            if (!_isKeyboardUp) {
                scrollEdit.Frame = new CGRect (scrollEdit.Frame.X, scrollEdit.Frame.Y, scrollEdit.Frame.Width, scrollEdit.Frame.Height - _keyboardHeight);
                scrollEdit.ContentSize = viewEdit.Frame.Size;
                isKeyboardUp = true;
            }
        }
    
        private void KeyBoardDownNotification (NSNotification notification)
        {
            if (_isKeyboardUp) {
                scrollEdit.Frame = new CGRect (scrollEdit.Frame.X, scrollEdit.Frame.Y, scrollEdit.Frame.Width, scrollEdit.Frame.Height + _keyboardHeight);
                scrollEdit.ContentSize = viewEdit.Frame.Size;
                isKeyboardUp = false;
                View.EndEditing (true);
            }
        }
    

A few details on the code:

  • I see the notifications firing, and enter the corresponding handler code.
  • scrollEdit frame size is (X=0, Y=0, Width=960, Height=630)
  • viewEdit frame size is (X=0, Y=0, Width=960, Height=630)

When I click on any text field, the keyboard attempts to pop up, but nothing happens, and the entire view is "locked". The app is not crashing, or freezing, I just can't click on anything else (almost as if there's a transparent view laying on top of my modal blocking touch actions from hitting the controls).

Any ideas what could be causing this?

Tagged:

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    You just show the WillShowNotification and WillHideNotification, what about your scrollEdit and viewEdit? Try to provide a sample which can be run on my side to reproduce your issues.

  • LeeMcOmberLeeMcOmber USMember

    Following up here, the issue was resolved by changing how the modal was displayed.

    Previously our modals were being launched with the following presentation style:

    view.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
    

    Changing to this solves the issue:

    view.ModalPresentationStyle = UIModalPresentationStyle.OverFullScreen;
    
Sign In or Register to comment.