Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugzilla] DidRotate in a MTD app causes first responder to get lost #250

Open
dalexsoto opened this issue Apr 11, 2018 · 0 comments
Open

Comments

@dalexsoto
Copy link
Contributor

From https://bugzilla.xamarin.com/show_bug.cgi?id=17714:

Moved from discussion here: https://forums.xamarin.com/discussion/13341/restore-focus-after-rotate#latest

  1. Run this code.
  2. Select either the ID or Name control so that it has focus and the keyboard appears
  3. Rotate the device/simulator

//expected: Device to rotate and the first responder to remain as is with the keyboard selected
//actual: The device rotates, but the first responder is lost

Notes:

  • If you comment out the base.DidRotate() call, it works (but Apple wants you to call the base)
  • If you comment out the call to tableView.ReloadData() inside the ReloadData() method, it works (but I don't know what side effects that opens up)
  • Keeping the first responder and keyboard after rotation works in non-MTD apps
using System;
using MonoTouch.Dialog;
using MonoTouch.UIKit;

namespace MTDRotate
{
    public class HomeScreen: DialogViewController
    {
        public HomeScreen(): base(null, true)
        {
            Title = "Rotate Focus";
            Root = CreateRoot();
        }

        public RootElement CreateRoot()
        {           
            RootElement rootElement = new RootElement("Details");
            Section section = new Section("Test");
            section.Add(new EntryElement("ID", "", ""));
            section.Add(new EntryElement("Name", "", ""));
            rootElement.Add(section);
            return rootElement;
        }

        public override void DidRotate(MonoTouch.UIKit.UIInterfaceOrientation fromInterfaceOrientation)
        {
            base.DidRotate(fromInterfaceOrientation);
        }
    }
}

Comment from Rolf:

Apparently ReloadData should resign the first responder:

http://stackoverflow.com/questions/6409370/uitableview-reloaddata-resigns-first-responder

However we seem to need ReloadData to resize cells:

b55b51d

I'm not sure how to best solve this situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant