简体   繁体   English

将子视图置于键盘前面

[英]Bringing subview in front of keyboard

I have a page in which I am sending a message. 我有一个要发送消息的页面。 I have a UIView , with an UIActivityIndicatorView , which appears at the center of the screen when I click "send" and then disappears on delivery. 我有一个带有UIActivityIndicatorViewUIView ,当我单击“发送”时它出现在屏幕中央,然后在交付时消失。 This view is being hidden by the keyboard. 该视图已被键盘隐藏。 I want to know how to bring it in front of the keyboard because [UIView bringSubviewtoFront] doesn't work. 我想知道如何将其放在键盘前面,因为[UIView bringSubviewtoFront]不起作用。 Any ideas? 有任何想法吗?

If this view needs to block some portion of your keyboard then I'm assuming at that point you don't need the keyboard. 如果此视图需要遮挡键盘的某些部分,那么我假设此时您不需要键盘。 If you don't need the keyboard you should dismiss it using [someTextView resignFirstResponder]; 如果不需要键盘,则应使用[someTextView resignFirstResponder];将其关闭[someTextView resignFirstResponder];

pro-tip - in IOS, when you gotta bend over backwards to do something, you are probably doing it the wrong way. 专业提示-在IOS中,当您向后弯腰去做某事时,您可能会以错误的方式进行操作。

This code Worked for me try it. 此代码对我有用,请尝试一下。 hope it will helps you 希望对您有帮助

UIWindow *window = [UIApplication sharedApplication].windows.lastObject;
[window addSubview:self.view];                                                                                                                                                                                                                                        
[window bringSubviewToFront:self.view];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM