I have a xamarin project that is initialized through c# code (I deleted the main.storyboard file), initialization occurs in the appDelegate class and SceneDelegate, the project contains tabs. The application starts without errors, all controllers are displayed correctly, but when you click on UITextView, the keyboard does not appear, although the textView itself is active and the cursor on it blinks
code in AppDelegate
public bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
Window = new UIWindow(UIScreen.MainScreen.Bounds);
var tabBar = new UITabBarController();
var firstFirstController = new FirstViewController();
tabBar.ViewControllers = new UIViewController[]
{
firstFirstController
};
Window.RootViewController = tabBar;
Window.MakeKeyAndVisible();
return true;
}
code in SceneDelegate
public void WillConnect (UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
{
var windowScence = new UIWindowScene(session, connectionOptions);
Window = new UIWindow(windowScence);
var tabBar = storyboard.InstantiateViewController("tabBar") as UITabBarController;
var firstFirstController = storyboard.InstantiateViewController("firstViewController") as FirstViewController;
firstFirstController.lb.Text = "BYE";
tabBar.ViewControllers = new UIViewController[]
{
firstFirstController
};
Window.RootViewController = tabBar;
Window.MakeKeyAndVisible();
}
code in FirstViewController
public partial class FirstViewController : UIViewController
{
public UILabel lb;
public UITextView tb;
public FirstViewController (IntPtr handle) : base (handle)
{
lb = new UILabel();
lb.Frame = new CoreGraphics.CGRect(100, 100, 100, 40);
lb.TextColor = UIColor.Black;
lb.Text = "HELLO";
tb = new UITextView(new CoreGraphics.CGRect(200, 200, 100, 40));
tb.BackgroundColor = UIColor.Black;
tb.Started += Tb_Started;
}
private void Tb_Started(object sender, EventArgs e)
{
tb.BecomeFirstResponder();
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
View.AddSubviews(lb, tb);
}
public override void DidReceiveMemoryWarning ()
{
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
}
i was exposing textView.UserInteractionEnabled = true tried calling becomeFirstResponder start with tabBar
I also tried to create a new project and deleted the main.storyboard file, initialization occurs in the AppDelegate class and SceneDelegate, and then encountered the same problem as you, I modified the code in
SceneDelegateas follows and it worked fine: