paulpatarinski / Xamarin.Forms.Plugins

Xamarin Forms Plugins
http://paulpatarinski.github.io/Xamarin.Forms.Plugins
MIT License
276 stars 141 forks source link

KeyboardOverlap: System.ObjectDisposedException has been thrown. #163

Open dzmitry-antonenka opened 5 years ago

dzmitry-antonenka commented 5 years ago

The exception message is: Cannot access a disposed object. Object name: 'KeyboardOverlapRenderer'

Call stack: UIKit.UIApplication.UIApplicationMain() in UIKit.UIApplication.Main(string[] args, System.IntPtr principal, System.IntPtr delegate) in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:79 UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName) in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:63 iOS.Application.Main(string[] args) in …/Main.cs:17

ikeremozcan commented 5 years ago

I have the same problem either, especially happens in debug mode a lot

aparnatiwari30 commented 5 years ago

I also have the same problem. Error Message: Unhandled Exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'KeyboardOverlapRenderer'.

omanak commented 5 years ago

Has anyone had any luck with this? I am experiencing the same issue.

cooliopas commented 5 years ago

Same problem here :(

icalderond commented 5 years ago

I have same problem: Cannot access a disposed object. Object name: 'KeyboardOverlapRenderer'.

stivenbr commented 5 years ago

"Solution" ?

Hello, In my case it happens when I close the session with masterdetailpage, to solve it we have to close the menu with IsPresented and leave a waiting time to perform the navigation.

Example with PRISM MVVM and MessagingCenter.

MasterPageViewModel.cs (Method)

private async void Logout() 
{
     MessagingCenter.Send(this, "Logout");
     await Task.Delay(500);

     // Navigation Login
     await this.NavigationService.NavigateAsync(new Uri("/LoginPage", UriKind.Absolute));
}

MasterPage.xaml.cs

namespace ProjectXamarin.Views
{
    using ProjectXamarin.ViewModels;
    using Xamarin.Forms;

    public partial class MasterPage : MasterDetailPage
    {
        public MasterPage()
        {
            InitializeComponent();

            // Close Menu
            MessagingCenter.Unsubscribe<MasterPageViewModel>(this, "Logout");
            MessagingCenter.Subscribe<MasterPageViewModel>(this, "Logout", (sender) =>
            {
                this.CloseMenu();
            });
        }

        private void CloseMenu() 
        {
            this.IsPresented = false;
        }
    }
}

Sorry my English (Google translator).

rmgalante commented 5 years ago

I confirmed that stivenbr's solution worked for me. I'm build an app using the Prism framework. So my changes went into one file, the view model class.

MasterDetailPageViewModel.cs

private async Task ItemTappedAsync(MasterDetailPageMenuItem menuItem)
{
        // If the user is logging out, navigate to the LoginPage and make it the main page.
        if (menuItem.Title == Constants.LogoutPage)
        {
                await NavigationService.GoBackToRootAsync();
                // Prevent unhandled exception, System.ObjectDisposedException, on object, KeyboardOverlapRenderer.
                MasterDetailPage1 page = (App.Current.MainPage as MasterDetailPage1);
                if (page != null)
                {
                        page.IsPresented = false;                        
                }
                // Relinquish control to the UI thread
                await Task.Delay(500);
                // Now navigate to the LoginPage
                await NavigationService.NavigateAsync(Constants.LoginPageUri);
                return;
        }
}