What is the API to remove the additional UIWindows (I have more than one) from UIApplication?
Long Version:
=========
I am trying to add two UIWindows in an app. I am using the second UIWindow to implement a view similar to UIActionSheet.
I can achieve the same by adding the new view to the existing UIWindow, but UIActionSheet does it by adding a new UIWindow and setting the windowLevel and I thought I may also implement in the same fashion.
I was able to create a new UIWindow, add new views and I was able to display it on top of the existing UIWindow by making a call to makeKeyAndVisible. I verified that it is reflected in the "windows" property of UIApplication as well.
The problem I am facing is I can't find any API to remove the new UIWindow from the list of windows in UIApplication. I tried calling makeKeyAndVisible on the previous window and it makes the new window disappear. But all the key presses are still going to the new UIWindow views.
How can I remove the new UIWindow from the windows list of the app?
Yeah I have looked at AppProgramming Guide and it does mention the same. I have working code using a single UIWindow.
I am trying to create a clone of UIActionSheet and UIActionSheet itself uses additional UIWindow for its functionality. It seems to be a little more elegant solution than adding these additional views on to the same UIWindow.
Let me know if you know how to remove the extra UIWindow from the list.
Quote:
Originally Posted by macoholic
You should not use more than one Window in an application....an application can have multiple views but only one window....
AS per iPhoneAppProgrammingGuide from apple you should not create more than one UIWindow in an App.
Your extra UIWindow in this case will be a sub view to your parent view or Window.
You could get the array of sub views and then remove what you want.
A suggestion...if apple suggests use a single UIWindow it's better to stick to it!
No harm experimenting but I am sure what you are truing to do can be done using Views too...coz primarily a UIWindow is derived from UIView.
Additional I have seen that not following apple's suggestion can lead to necessary performance issues...leaks and all.....
Any ways that's my point of view...see if the above suggestion helps you get rid of the extra UIWindow.....
If it doesn't and there is an alternate solution do let me know
The new UIWindow is not present in the same view heirarchy. It is present in an array of UIWindows (property "windows", readonly) in UIApplication. I can't find any API to remove it from this list.
I captured the view heirarchy for both the UIWindows and they sit at the same level (This view heirarchy is from a UIActionSheet and not from my code). I have truncated the main UIWindow view heirarchy, but it gives the idea.
Your extra UIWindow in this case will be a sub view to your parent view or Window.
You could get the array of sub views and then remove what you want.
A suggestion...if apple suggests use a single UIWindow it's better to stick to it!
No harm experimenting but I am sure what you are truing to do can be done using Views too...coz primarily a UIWindow is derived from UIView.
Additional I have seen that not following apple's suggestion can lead to necessary performance issues...leaks and all.....
Any ways that's my point of view...see if the above suggestion helps you get rid of the extra UIWindow.....
If it doesn't and there is an alternate solution do let me know
After you've added a window to your hierarchy via -makeKeyAndVisible, you can remove it from the screen by calling it's -resignKeyWindow method.
Quote:
Originally Posted by siasl
The new UIWindow is not present in the same view heirarchy. It is present in an array of UIWindows (property "windows", readonly) in UIApplication. I can't find any API to remove it from this list.
I captured the view heirarchy for both the UIWindows and they sit at the same level (This view heirarchy is from a UIActionSheet and not from my code). I have truncated the main UIWindow view heirarchy, but it gives the idea.