3

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];
}
Community
  • 1
  • 1
AliBZ
  • 4,039
  • 12
  • 45
  • 67

1 Answers1

2

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].

AliBZ
  • 4,039
  • 12
  • 45
  • 67
  • Why are you adding a new window? iOS applications should only have one window, and it should only be set in the AppDelegate. – AMayes Mar 21 '13 at 18:11
  • 2
    I believe you are wrong. Take a look at http://stackoverflow.com/questions/8232398/advantages-problems-examples-of-adding-another-uiwindow-to-an-ios-app – AliBZ Mar 21 '13 at 18:12
  • "Unless an app can display content on an external device screen, an app has only one window." [UIWindow documentation](http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html). – AMayes Mar 21 '13 at 18:20