Search code examples
ioskeyboarduiwindow

Keyboard doesn't come up with multiple UIWindows


I have created a loading UIWindow which I call and makeKeyAndVisible when I start loading. After I'm finished, I makeKeyAndVisible my main UIWindow. But my problem is after doing this, when I click on a text field, the keyboard doesn't come up. This is asked in Cursor is blinking in UITextField but keyboard doesn't appear but I can't find the right answer.

EDIT: in UIView, when I click on the addressbar, keyboard does come up but I can't type. But in google's page, when I click on search text field, keyboard doesn't come up.

- (void)showLoading:(NSString*)text
{
loadingWindow = [[UIWindow alloc] init];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
mainWindow = UIApplication.sharedApplication.keyWindow;    

[loadingWindow setFrame:CGRectMake(0, 0, boundWidth, boundHeight)];
[loadingWindow setRootViewController:[[UIViewController alloc] init]];
[loadingWindow.rootViewController setView:[[UIView alloc] init]];
[loadingWindow.rootViewController.view setFrame:loadingWindow.frame];

[loadingWindow setHidden:NO];
}

- (void)hideLoading
{
[loadingWindow setHidden:YES];
[loadingWindow removeFromSuperview];
}

Solution

  • I found the problem. When I wanted to put the loadingWindow on top, I was calling [loadingWindow makeKeyAndVisible] which I believe leads to the problem. Now I only use [loadingWindow setHidden:NO].