Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Why is TextField not accepting input?

GerryRempelGerryRempel CAMember ✭✭

I have an ios App created in Xamarin with Visual Studio on the Mac. I've modified SceneDelegate to load a UITabController that is not created on the Storyboard. I've done this to allow changing the number of tabs presented in some cases.

The UITabController is adding a View that is defined on the Storyboard. This view contains a TextField, this textfield does not allow text entry. When you tap it a keyboard does not appear.

Yes User Interaction Enabled is checked.

How can I fix this? Thanks, Gerry

Best Answer


  • ColeXColeX Member, Xamarin Team Xamurai
    edited March 2020

    I know UITabbarController and UITableViewController but not UITabController ,do you mean UITabbarController here ?

    How you add View into UITabController ? Could you post this part of code ?

    It's better to post a basic , minimum project here , we need to reproduce the problem first .

  • GerryRempelGerryRempel CAMember ✭✭

    I meant UITabbarController.

    This is my custom UITabbarController class:
    public class TabController : UITabBarController
    public TabController()
    UIViewController t1;

            t1 = new UIViewController();
            t1.Title = "Greeen";
            t1.View.BackgroundColor = UIColor.Green;
            var story = UIStoryboard.FromName("Main", null);
            UIViewController v1 = story.InstantiateViewController("ViewId");
            v1.Title = "First";
            var tabs = new UIViewController[] { v1, t1 };
            ViewControllers = tabs;

    This is my appdelegate code:
    public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    Window = new UIWindow(UIScreen.MainScreen.Bounds);
    UIViewController vc = new TabController();
    Window.RootViewController = vc;

            return true;

    This is scene delegate:
    public void WillConnect(UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
    Window = new UIWindow(new UIWindowScene(session, connectionOptions));
    UIViewController vc = new test4.TabController();
    Window.RootViewController = vc;

    The UIViewController "ViewId" is a simple UIViewController from the Storyboard that contains a text input field. The clear button on the UITextField works, but the keyboard never pops up so that you can enter text.

    The other weird thing is that the "ViewId" is still marked as initial view controller in the storyboard, and you cannot change that.


  • ColeXColeX Member, Xamarin Team Xamurai
    edited March 2020

    I test your code , problem resolved after removing the code in WillConnect in scene delegate .

    If you do not need to use multiple Scene , just remove the code in scene delegate , you can change root view controller in AppDelegate .

  • GerryRempelGerryRempel CAMember ✭✭

    Thanks, it worked a charm.

Sign In or Register to comment.