MBProgressHUD 无法覆盖键盘
当我尝试在键盘也显示的情况下显示 MBProgressHUD 时,我使用下面的代码,但 HUD 对象无法覆盖键盘:
SNSSharerAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
HUD = [[MBProgressHUD showHUDAddedTo:delegate.window animated:YES] retain];
HUD.mode = MBProgressHUDModeIndeterminate;
HUD.labelText = @"Posting...";
[HUD show:YES];
我认为 HUD 对象显示在委托窗口前面,键盘也显示,所以添加了最后,即前面。我错了吗?
When I try to show a MBProgressHUD while the keyboard is also showing, I use the code below but the HUD object cannot cover the keyboard:
SNSSharerAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
HUD = [[MBProgressHUD showHUDAddedTo:delegate.window animated:YES] retain];
HUD.mode = MBProgressHUDModeIndeterminate;
HUD.labelText = @"Posting...";
[HUD show:YES];
I thought the HUD object shows in front of the window of delegate, the keyboard shows too, so which added last, which is front. Am I wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 hud 添加到包含键盘的第二个窗口。
当键盘显示时,应用程序中有两个 UIWindow 实例。第一个是常规窗口,第二个是临时键盘窗口。
代码:
在ios4.3和ios5.x中测试,确实有效。
Add hud to the second window which contains the keyboard.
When keyboard showing, there are two UIWindow instances in application. The first one is the regular window, the second one is the temp keyboard window.
Code:
Tested in ios4.3 and ios5.x, it really works.
对于ios 9,改为 [[[UIApplication sharedApplication] windows] objectAtIndex:1] 尝试使用 [[[UIApplication sharedApplication] windows] lastObject]
所以它会像这样
for ios 9 instead [[[UIApplication sharedApplication] windows] objectAtIndex:1] try use [[[UIApplication sharedApplication] windows] lastObject]
so it will be like this