如何通过键盘 - iOS添加UIView [英] How to add a UIView over the Keyboard - iOS

查看:148
本文介绍了如何通过键盘 - iOS添加UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在iOS上显示toast讯息。我做的是当任何通知来了,只是我采取了导航控制器视图,并添加了一个子视图我的烤面包消息和显示。

I have been trying to display a toast message on iOS. What I did was when any notification comes, just I took the navigation controller view and added a subview for my toast message and displayed.

    UIView *top_view = self.navigationController.view;
    [top_view showToast:string];

一切正常。然而,我的烤面包视图不是通过键盘添加(如果键盘在前面)。任何想法可能是问题...小帮助可以节省我的时间... Thanx ..

Everything works fine. However my toast view is not adding over the keyboard(if the keyboard is at the front). Any idea what could be the problem... Little helps may save my time... Thanx..

推荐答案

UIWindow *toastDisplaywindow = [[[UIApplication sharedApplication] delegate] window];;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) 
{
   if (![[testWindow class] isEqual:[UIWindow class]]) 
    {
       self.toastDisplaywindow = testWindow;
       break;
    }
}
[toastDisplaywindow showToast:string];

如果正在显示键盘,它将显示为一个单独的窗口, 。因此,进行检查以确定是否正在显示键盘。

If a keyboard is being displayed, it will be displayed as a separate window, above your usual main window. Hence a check made to find out if the keyboard is being displayed. If it is, then add the toast message on that window, else on the main window.

我在这个链接,使用它可以直接访问键盘的UIView(如果需要)。

I found another method in this link, using which you can directly get to the UIView of the keyboard (If required).

这篇关于如何通过键盘 - iOS添加UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆