键盘出现在视图顶部,不允许用户交互
我有一个基于窗口的项目,有两个 UITextField 来获取用户的输入。 两者都在我的视图控制器中。
我必须在后台解析内容,因此我需要同时阻止用户交互的东西。 我遇到了这个 Cocoa With Love 教程来创建一个在所有内容之上加载视图。实际上,在大多数情况下,它运行得很好;当文本字段放弃第一响应者时它就会起作用。
但在一种情况下它不起作用。当我在第一个文本字段中输入内容然后选择第二个文本字段时,将出现加载屏幕,但键盘位于其顶部,因此用户可以输入内容。我希望加载屏幕位于键盘顶部。
在教程中,它说调用键盘的超级视图。键盘的超级视图是什么? 我在视图控制器中尝试了以下不同的片段,但没有任何效果。
loadingView = [LoadingView loadingViewInView:[self.view.window.subviews objectAtIndex:0]];
loadingView = [LoadingView loadingViewInView:self.view];
loadingView = [LoadingView loadingViewInView:self.view.superview];
如何使加载屏幕出现在所有内容之上?
I have a window-based project with two UITextField
s to take input from the user.
Both are in my view controller.
I have to parse stuff in the background, so I need something that blocks user interaction in the meanwhile.
I came across this Cocoa With Love tutorial to create a loading view on top of everything. It actually works pretty well, for the most part; it works when ever the text field resigns first responder.
There is one circumstance where it doesnt work, though. When I type something in the first text field and then select the second one, the loading screen will appear, but the keyboard is on top of it, so the user could type something. I want the loading screen to be on top of the keyboard.
In the tutorial, it says to call the keyboard's superview. What is the keyboard's superview?
I tried the following different snippets in my view controller, but nothing works.
loadingView = [LoadingView loadingViewInView:[self.view.window.subviews objectAtIndex:0]];
loadingView = [LoadingView loadingViewInView:self.view];
loadingView = [LoadingView loadingViewInView:self.view.superview];
How can I make the loading screen appear on top of everything ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的解决方案是在显示加载视图时关闭键盘。我认为你不可以在键盘上放置任何东西。
也就是说,您可以尝试使用根窗口作为视图,看看是否有任何效果。
The simple solution is to dismiss the keyboard when you show the loading view. I don't think you're allowed to put anything on top of the keyboard.
That said, you could try using the root window as the view to see if that has any effect.