There is a view with UITextView on it. UITextView is the only one possible firstResponder for keyboard. Let's call it "BackView".
There is another view which is PopUp (full screen view with transparent background which fades underlying view). Let's call it "PopUp".
PopUp works fine except when the keyboard is on screen. Presenting PopUp forces keyboard to be hidden and, when the PopUp is dismissed, the keyboard is shown again. Since the PopUp is not covering whole BackView it does not look good.
Is there any way to keep keyboard on BackView while PopUp is shown? (there is no need to use keyboard in popup).
PopUp contains:
PopUp is shown with:
[self setModalPresentationStyle:UIModalPresentationCurrentContext];
[self presentViewController:vc animated:YES completion:nil];
Found solution:
Add PopUp view as a subview for current window
mb.server answered his own question (one that I had as well). But I just wanted to spell out the code explicitly for the benefit of others:
//instantiate popUpVC, then
popUpVC.view.frame = [UIScreen mainScreen].bounds; //assuming you wish the popover to occupy the entire screen; adjust as needed
UIWindow* currentWindow = [[[UIApplication sharedApplication] windows] lastObject];
[currentWindow addSubview:popUpVC.view];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With