Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当UIWindow不在第一个位置的时候,弹窗弹不出来 #31

Open
jiaxiaoru opened this issue Nov 26, 2018 · 4 comments
Open

当UIWindow不在第一个位置的时候,弹窗弹不出来 #31

jiaxiaoru opened this issue Nov 26, 2018 · 4 comments

Comments

@jiaxiaoru
Copy link

这个现象出现在我们的App第一次安装的时候,[UIApplication sharedApplication].windows 这个获取到的windows数组如下:
<__NSArrayM 0x6000022bf9c0>(
<UITextEffectsWindow: 0x7fe724227800; frame = (0 0; 414 896); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x600002c38ac0>>,
<UIWindow: 0x7fe723f453b0; frame = (0 0; 414 896); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.117647 0.8 0.431373 1; gestureRecognizers = <NSArray: 0x600002259a40>; layer = <UIWindowLayer: 0x600002cbf3e0>>,
<UITextEffectsWindow: 0x7fe725029a00; frame = (0 0; 414 896); layer = <UIWindowLayer: 0x600002c3e160>>,
<UIRemoteKeyboardWindow: 0x7fe725107400; frame = (0 0; 414 896); opaque = NO; autoresize = W+H; layer = <UIWindowLayer: 0x600002c3e0e0>>
)
如果取第一个的话,弹窗就弹不出来,关闭App,重新打开App又好了,所以觉得
#define kCurrentWindow [[UIApplication sharedApplication].windows firstObject]
这行代码有问题,应该要判断下取到的是否是UIWindow,windowlevel是否为normal,我们这边能改,但是代码不好管理,希望你们能在下个版本解决下这个问题,辛苦了。

@12207480
Copy link
Owner


keywindow吧

@jiaxiaoru
Copy link
Author


keywindow吧
大部分情况下用keywindow是可以的,但是如果取keywindow前系统有弹过窗(UIAlertView)并且没消失,此时取到的keywindow会是UIAlertControllerShimPresenterWindow,而不是UIWindow,所以是建议这样获取[[[UIApplication sharedApplication] delegate] window]

@12207480
Copy link
Owner

好提议

@SylarCao
Copy link

SylarCao commented Feb 1, 2019


keywindow吧
大部分情况下用keywindow是可以的,但是如果取keywindow前系统有弹过窗(UIAlertView)并且没消失,此时取到的keywindow会是UIAlertControllerShimPresenterWindow,而不是UIWindow,所以是建议这样获取[[[UIApplication sharedApplication] delegate] window]

对呀 为什么不用 [[UIApplication sharedApplication] keyWindow]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants