I have a UITabViewController
set up with two tabs, the second containing a web browser. The keyboard will not appear in my App unless I first display and dismiss a UIAlertView
in the first tab. What could possibly be wrong?
问题:
回答1:
Solved; I accidentally removed:
[window makeKeyAndVisible];
回答2:
The solution mentioned here didn't work for me. I had a persistent error that seemed to be an issue with iOS, or at least my build settings. I came up with a workaround. If you're still stuck like I was, try this. I think it will work. Here it is briefly. Check out my post if you need more detail.
Put this into your web view's delegate:
- (BOOL)webView:(UIWebView *)v shouldStartLoadWithRequest:(NSURLRequest *)r navigationType:(UIWebViewNavigationType)t {
NSString *requestString = [[r URL] absoluteString];
if ([requestString hasPrefix: @"yourURLPrefix:"] ) {
if ([requestString hasPrefix: @"yourURLPrefix:keyboardFix"] ) {
[v.window makeKeyAndVisible];
}
}
Put this into the onFocus event handler of any input element you need to reliably bring up the keyboard:
document.location = "yourURLPrefix:keyboardFix";
回答3:
Not a lot to go on but if you have textfield visually displayed but it will not evoke the keyboard when tapped then most likely you have an issue with focus i.e. the view containing the textfield does not believe it should intercept taps. This usually occurs because another view is visually in-front (below in the logical view hierarchy) of the view containing the text field. Presumably, displaying and then dismissing the alert alters the view hierarchy and lets the textfield intercept taps.
That's what I would check first.
回答4:
For me the issue was a 3rd party lib I used DCIntrospect(very recommended), it has a bug which prevents from the Keyboard to appear in UIWebViews. An issue was open https://github.com/domesticcatsoftware/DCIntrospect/issues/36
回答5:
I found that [(window) makeKeyAndVisible] did the trick here.
If you are trying to use makeKeyAndVisible and it doesn't seem to do anything, very likely you are sending that message to a null object--that is what I ran into. Use NSLog() to check the identity of the Window that you will be sending that message to.
Once I found the right Window object, it worked fine.