Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to activate the keyboard from a UITextView on a (secondary) UIWindow
    text
    copied!<p>My iPhone app (based on the "Single View Application" of Xcode) has a UITextView (say: myTextView) that I want the user to be able to edit. I was setting it to editable, and all was working fine (I didn't even have to invoke becomeFirstResponder).</p> <p>Then I moved it in another UIWindow (say: newWindow) (on top of the main/root/key one that is called self.window (of the Single View App.)). </p> <p>But now, when I click on the UITextView, the keyboard does not show.</p> <p>Everything works if I do this:</p> <blockquote> <p>[myTextView setEditable:YES];<br> [myTextView becomeFirstResponder]; // ugly...and I do not need it, but I added it just in case...<br> [self.window addSubview:newWindow];<br></p> </blockquote> <p>but the keyboard is shown immediately (since I set becomeFirstResponder) that is not nice. But if I remove the becomeFirstResponder line, the keyboard does not show <strong>at all</strong>!</p> <p>If I move the [self.window addSubview:newWindow] line above, then no matter what I do, the keyboard is not activated...</p> <blockquote> <p>[self.window addSubview:newWindow]; // this is how it should be... but,<br> [myTextView setEditable:YES];<br> [myTextView becomeFirstResponder]; // even when I enter this, it's not working :-(<br></p> </blockquote> <p>I tried [newWindow makeKeyAndVisible] nothing. I tried to add a touch delegate and detect a touch (or a gesture) on the UITextView, they work (I get the NSLog message I included), but again, no keyboard. I even tried to add another field (of the main window) on top of newWindow (so as to have a main window element on top), still no luck...</p> <p>What am I missing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload