app在iOS11下存在一个bug是点击图片不能显示大图
调试发现是因为在iOS11上把大图添加到window上之后不显示
代码语言:txt复制 for (int i = [UIApplication sharedApplication].windows.count - 1; i >= 0; i--) {
UIWindow *window = [UIApplication sharedApplication].windows[i];
if (window.frame.size.width == [UIApplication sharedApplication].keyWindow.size.width &&
window.frame.size.height == [UIApplication sharedApplication].keyWindow.size.height) {
lastFullWindow = window;
break;
}
}
在iOS11中,使用UIApplication sharedApplication.windows获取的最顶层的window为_UIInteractiveHighlightEffectWindow,并且其hidden = YES,所以在上面添加内容显示不出来。
代码语言:txt复制// iOS11种多出来一个不可见的全屏window
<_UIInteractiveHighlightEffectWindow: 0x11b4647c0; frame = (0 0; 414 736); hidden = YES; opaque = NO; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x1c4a42850>; layer = <UIWindowLayer: 0x1c483cf20>>
若之前未在keyWindow中添加其它内容,可以直接修改为UIApplication sharedApplication.keyWindow,或者对window的hidden属性进行判断,向下遍历直到获得可以显示出来的全屏window。
代码语言:txt复制 for (int i = [UIApplication sharedApplication].windows.count - 1; i >= 0; i--) {
UIWindow *window = [UIApplication sharedApplication].windows[i];
if (window.frame.size.width == [UIApplication sharedApplication].keyWindow.size.width &&
window.frame.size.height == [UIApplication sharedApplication].keyWindow.size.height &&
window.hidden == NO) {
lastFullWindow = window;
break;
}
}