iOS - 获取系统键盘所在View
来源:互联网 发布:淘宝网惊现美女火辣 编辑:程序博客网 时间:2024/06/13 07:22
做自定义键盘可能需要用到这个,也有用更高级别的Window盖住键盘,这个在键盘view上用自定义键盘盖住原键盘,但是记得不需要的时候就把自定义键盘移除,否则在哪都是自定义键盘
代码是从Stack Overflow找到的,好用
- (UIView *)keyboardView{ UIWindow* tempWindow; //Because we cant get access to the UIKeyboard throught the SDK we will just use UIView. //UIKeyboard is a subclass of UIView anyways UIView* keyboard; NSLog(@"windows %ld", [[[UIApplication sharedApplication]windows]count]); //Check each window in our application for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; c ++) { //Get a reference of the current window tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c]; //Get a reference of the current view for(int i = 0; i < [tempWindow.subviews count]; i++) { keyboard = [tempWindow.subviews objectAtIndex:i]; NSLog(@"view: %@, on index: %d, class: %@", [keyboard description], i, [[tempWindow.subviews objectAtIndex:i] class]); if([[keyboard description] hasPrefix:@"(lessThen)UIKeyboard"] == YES) { //If we get to this point, then our UIView "keyboard" is referencing our keyboard. return keyboard; } } for(UIView* potentialKeyboard in tempWindow.subviews) // if the real keyboard-view is found, remember it. if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { if([[potentialKeyboard description] hasPrefix:@"<UILayoutContainerView"] == YES) keyboard = potentialKeyboard; } else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) { if([[potentialKeyboard description] hasPrefix:@"<UIPeripheralHost"] == YES) keyboard = potentialKeyboard; } else { if([[potentialKeyboard description] hasPrefix:@"<UIKeyboard"] == YES) keyboard = potentialKeyboard; } } return keyboard;}
0 0
- iOS - 获取系统键盘所在View
- 获取系统键盘所在的View
- iOS-获取当前View所在的控制器
- iOS-获取当前View所在的控制器
- iOS-获取当前View所在的控制器
- 如何获取视图view所在的控制器iOS
- 【iOS开发】获取当前view(视图)所在的Controller(控制器)
- iOS开发之获取view所在的控制器
- 获取view所在的控制器
- 获取 view 所在的ViewController
- iOS获取系统键盘的高度
- iOS如何获取系统键盘的高度
- iOS开发—获取系统键盘高度
- iOS 获取系统键盘UIKeyboard方法
- IOS开发之自定义系统弹出键盘上方的view
- IOS开发之自定义系统弹出键盘上方的view
- IOS开发之自定义系统弹出键盘上方的view
- 获取当前view所在页面的viewController
- Java 对象生命周期
- JVM处于全局停顿 本地代码可执行
- 回顾一下排序
- Python三目运算符
- iOS悬停
- iOS - 获取系统键盘所在View
- oc-Foundation_05_装箱和开箱——NSNumber_NSValue
- servlet请求转发与重定向的区别 简单易懂
- Spark编程指南入门之Java篇五-数据重组Shuffle介绍
- ViewPager和lisitView的组合使用
- python3.0 网络爬虫 5
- ArcPy列举字段
- 【问题处理】CocoaPods卡住在Updating local specs repositories的解决办法
- SpringBoot 文档根元素 "beans" 必须匹配 DOCTYPE 根 "null"