How do I identify the gamekit message window?

佐手、 提交于 2019-12-11 04:48:47

问题


When an iPhone app with GameKit launches, and the device is already logged in to GameCenter, a small message slides in on top of the screen, saying something along the lines of "Welcome back %username!".

What I found out is the following: that message appears in its own UIWindow that eventually slides the message away and releases itself. When the message is onscreen, you can log out the following:

all windows: ( "<UIWindow: 0x31fc70; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x31fe60>>", "<UIWindow: 0x3874c0; frame = (0 0; 320 480); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x387590>>" )

I need to distinguish the two windows in the general case -- I need something along the lines of a -(UIWindow *)topNormalWindow function that will return the topmost window that isn't either A)an alert or B)the gamecenter message. I already have a -(UIWindow *)topNonAlertWindow that determines the top window that isn't an alert, but the gamekit message isn't, but nor is it (for my purposes) a normal window.

Also, what does autoresize = RM+BM; mean?


回答1:


I solved this problem by simply checking if the window had a GKGameEventView as a subview.




回答2:


I've been using Game Center and adding a notification system for achievements. I get the top window like this:

[[UIApplication sharedApplication] keyWindow]

Doesn't seem to conflict with alerts or the game center authentication window. In fact, my notifications get added under that window, so I think that one is on another layer above anything you can access.




回答3:


Regarding your last question:

What does autoresize = RM+BM; mean?

RM+BM is shorthand for the UIViewAutoresizing masks, UIViewAutoresizingFlexibleRightMargin and UIViewAutoresizingFlexibleBottomMargin, respectively. If you select a UI control in Interface Builder and go to the Size Inspector, the Autosizing graphic shows red "I-Beams" where the control is anchored to its bounding view. If Autoresizing = RM+BM, it means that you should see the top and left anchor beams (the I-Beams) in red, but the right and bottom ones are dimmed out. This essentially means that the right and bottom margins are flexible, and the layout manager is free to adjust them while rendering the view.



来源:https://stackoverflow.com/questions/3689448/how-do-i-identify-the-gamekit-message-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!