Location of New Window after old window closed
I have an app that allows multiple windows. I have a strange bug where, if I repeatedly open and close windows, new windows are positioned lower and lower on the screen. I would expect this if I were keeping 开发者_StackOverflowthe windows open, but it seems that the OS X window tiling mechanism is unaware of when my windows are closing.
Potentially relevant notes: I am using garbage collection. This is not a document-based app. When I close a window, the corresponding menu item is removed from the "Window" menu.
Any hints as to what I might be doing wrong would be appreciated. Thanks!
I remember running into this in my own application a while ago. As far as I could tell, this is just the way that Apple does things. I tried the same thing in other apps, and it was the same story.
Apple's documentation indicates that windows will cascade by default, but you can use the cascadeTopLeftFromPoint:
method if you want to change the default behaviour.
If you want the window to retain its position when re-opened, set a value for the window's Autosave
field in Interface Builder.
You can also set this programmatically using -setFrameAutosaveName:
.
精彩评论