bri*_*dge 7 hittest first-responder ios ios5
我正在尝试修复一个涉及UIView hitTest的错误:withEvent:当触摸在UIKeyboard上时,在我的视图上调用,但只有在应用程序处于后台之后.
它发生在我的应用程序中,具有复杂的视图层次结构,所以我在一个只有2个视图的应用程序中重现它:
行为如下:
我在iOS 5 iPad上看到这个2.但是只能在设备上,而不是在模拟器中.知道为什么hitTesting会以这种方式搞砸了吗?谢谢.
ipa*_*son 10
上面描述的问题似乎是由键盘的UIWindow卡在一个糟糕的状态引起的.确保键盘窗口的隐藏属性设置为YES(即使它已经是YES)也为我解决了问题.这可以在您的UIApplicationDelegate类中完成:
- (void)applicationWillEnterForeground:(UIApplication *)application {
// The keyboard sometimes disables interaction when the app enters the
// background due to an iOS bug. This brings it back to normal.
for (UIWindow *testWindow in [UIApplication sharedApplication].windows) {
if (!testWindow.opaque && [NSStringFromClass(testWindow.class) hasPrefix:@"UIText"]) {
BOOL wasHidden = testWindow.hidden;
testWindow.hidden = YES;
if (!wasHidden) {
testWindow.hidden = NO;
}
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
键盘窗口的类名称(至少在具有标准美国键盘的iOS 5中)是UITextEffectsWindow.像往常一样,依靠未记录的类名称并不是一个好主意,但在特定于操作系统的错误的情况下,它可以用于我的目的.可以有任意数量的窗口,包括根应用程序窗口,键盘,警报以及您的应用程序或其他框架添加的其他窗口,因此请勿过于明确.
归档时间: |
|
查看次数: |
1169 次 |
最近记录: |