Giter VIP home page Giter VIP logo

iosmauiscrolluponkeyboardshow's Introduction

iOSMauiScrollUpOnKeyboardShow

.NET Maui App that demonstrate how to scroll the page up when the keyboard is shown on iOS.

This affects only the iOS platform, Android (and hopefully the others) are unaffected and the behavior on these is the default one.

It works extending the ScrollView class and changing it's margin (top and bottom) if it's needed to.

The idea is taken from the KeyboardOverlap plugin for Xamarin.Forms.

Before (using default ScrollView)

before.mp4

After (using FixedScrollView)

after.mp4

iosmauiscrolluponkeyboardshow's People

Contributors

massijay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

asaleh-lab imemon

iosmauiscrolluponkeyboardshow's Issues

landscape mode keyboard popup too big

If you use your fix on an ipad in landscape mode you get either a big white area above the keyboard that blocks the entries (which can also not scroll away from) if your page is too long. Once your page is longer (?) than the keyboard + viewport the margin is bigger than reasonable. I also ran into this issue:

An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at W3AppMaui.Platforms.iOS.Utils.Extensions.GetViewRelativeBottom(UIView view, UIView rootView) in %myproject%\Platforms\iOS\Utils\Extensions.cs:line 44 at %myproject%.Platforms.iOS.Utils.Extensions.GetOverlapDistance(UIView activeView, UIView rootView, CGRect keyboardFrame) in %myproject%\Platforms\iOS\Utils\Extensions.cs:line 64 at %myproject%.Controls.FixedScrollView.OnKeyboardShowing(Object sender, UIKeyboardEventArgs args) in %myproject%\Controls\FixedScrollView.cs:line 26 at UIKit.UIKeyboard.Notifications.<>c__DisplayClass10_0.<ObserveWillShow>b__0(NSNotification notification) at Foundation.InternalNSNotificationHandler.Post(NSNotification s) at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) at W3AppMaui.Program.Main(String[] args) in %myproject%\Platforms\iOS\Program.cs:line 13 at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span1 args, BindingFlags invokeAttr)'`

FindFirstResponder returns null

Hi,

I cant seem to figure out why my app keeps crashing upon clicking on a textbox.
Ive traced the code to line 25 in the FixedScrollview.cs

UIView control = this.ToPlatform(Handler.MauiContext).FindFirstResponder();

control is null

I'm using .net7
Has anyone seen this before?

Bug if used with "Navigation" based app instead of "Shell" based app

Currently, if used with a Navigation-based app a null ref exception is thrown. I came up with this fix and I thought you might want to incorporate it (or something similar).

In FixedScrollView.cs ~line 23:

        private void OnKeyboardShowing(object sender, UIKeyboardEventArgs args)
        {
            // When Shell.Current is null use the top Navigation page.
            var cp = Shell.Current is null ? Navigation.NavigationStack.Last() : Shell.Current.CurrentPage;
            if (cp is ContentPage page)
            {   

Hope you find this usefull.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.