Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-27-2009, 02:26 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 17
siasl is on a distinguished road
Default Support multiple UIWindows in an app

Hi,

Short Version:
=========

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?

- siasl
siasl is offline   Reply With Quote
Old 05-27-2009, 02:33 AM   #2 (permalink)
Registered Member
 
macoholic's Avatar
 
Join Date: Dec 2008
Location: around a Mac...in Pune,India :)
Posts: 137
macoholic is on a distinguished road
Default

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.

Macoholic
macoholic is offline   Reply With Quote
Old 05-27-2009, 04:20 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 17
siasl is on a distinguished road
Default

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 View Post
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.

Macoholic
siasl is offline   Reply With Quote
Old 05-27-2009, 04:35 AM   #4 (permalink)
Registered Member
 
macoholic's Avatar
 
Join Date: Dec 2008
Location: around a Mac...in Pune,India :)
Posts: 137
macoholic is on a distinguished road
Default

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


Macoholic
macoholic is offline   Reply With Quote
Old 05-27-2009, 05:17 AM   #5 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 17
siasl is on a distinguished road
Default

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.


Code:
Main UIWindow
==========

2009-05-27 15:42:23.710 HG[39753:20b] UILayoutContainerView:[{{0, 20}, {320, 460}}]
2009-05-27 15:42:23.711 HG[39753:20b] .  UITransitionView:[{{0, 0}, {320, 411}}]
2009-05-27 15:42:23.715 HG[39753:20b] .  .  UILayoutContainerView:[{{0, 0}, {320, 411}}]
2009-05-27 15:42:23.716 HG[39753:20b] .  .  .  UITransitionView:[{{0, 44}, {320, 367}}]
2009-05-27 15:42:23.718 HG[39753:20b] .  .  .  .  UIView:[{{0, 0}, {320, 367}}]
2009-05-27 15:42:23.718 HG[39753:20b] .  .  .  .  .  UIView:[{{0, 0}, {320, 367}}]
2009-05-27 15:42:23.726 HG[39753:20b] .  .  .  .  .  .  HGTableView:[{{0, 0}, {320, 367}}]
2009-05-27 15:42:23.726 HG[39753:20b] .  .  .  .  .  .  .  HGBaseNewDetailedTableViewCell:[{{0, 5}, {320, 45}}]
2009-05-27 15:42:23.726 HG[39753:20b] .  .  .  .  .  .  .  .  UIGroupTableViewCellBackground:[{{41, 0}, {270, 45}}]
2009-05-27 15:42:23.732 HG[39753:20b] .  .  .  .  .  .  .  .  .  UIImageView:[{{0, 0}, {270, 45}}]
2009-05-27 15:42:23.733 HG[39753:20b] .  .  .  .  .  .  .  .  UIView:[{{42, 1}, {245, 43}}]
2009-05-27 15:42:23.733 HG[39753:20b] .  .  .  .  .  .  .  .  .  UILabel:[{{10, 10}, {80, 23}}]
2009-05-27 15:42:23.735 HG[39753:20b] .  .  .  .  .  .  .  .  .  UILabel:[{{90, 10}, {145, 23}}]
2009-05-27 15:42:23.736 HG[39753:20b] .  .  .  .  .  .  .  .  .  UILabel:[{{10, 10}, {180, 23}}]
2009-05-27 15:42:23.739 HG[39753:20b] .  .  .  .  .  .  .  .  _UITableViewCellRemoveControl:[{{0, 0}, {41, 45}}]
2009-05-27 15:42:23.740 HG[39753:20b] .  .  .  .  .  .  .  .  .  UIRemoveControlMinusButton:[{{0, 0}, {41, 45}}]
2009-05-27 15:42:23.740 HG[39753:20b] .  .  .  .  .  .  .  .  .  .  UIImageView:[{{14, 22}, {13, 3}}]
.
.
.
.
truncated
.
.
.
.

UIActionSheet UIWindow:
================

2009-05-27 15:42:23.852 HG[39753:20b] UIView:[{{0, 0}, {320, 480}}]
2009-05-27 15:42:23.853 HG[39753:20b] UIView:[{{0, 0}, {320, 480}}]
2009-05-27 15:42:23.853 HG[39753:20b] .  UIView:[{{0, 20}, {320, 460}}]
2009-05-27 15:42:23.854 HG[39753:20b] .  .  UIView:[{{0, 0}, {320, 411}}]
2009-05-27 15:42:23.854 HG[39753:20b] .  .  .  UIView:[{{0, 0}, {320, 411}}]
2009-05-27 15:42:23.856 HG[39753:20b] .  .  .  .  UIView:[{{0, 44}, {320, 367}}]
2009-05-27 15:42:23.856 HG[39753:20b] .  .  .  .  .  UIView:[{{0, 0}, {320, 367}}]
2009-05-27 15:42:23.857 HG[39753:20b] .  .  .  .  .  .  UIActionSheet:[{{0, 262}, {320, 154}}]
2009-05-27 15:42:23.859 HG[39753:20b] .  .  .  .  .  .  .  UIThreePartButton:[{{21, 21}, {278, 46}}]
2009-05-27 15:42:23.860 HG[39753:20b] .  .  .  .  .  .  .  UIThreePartButton:[{{21, 88}, {278, 46}}]
Quote:
Originally Posted by macoholic View Post
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


Macoholic
siasl is offline   Reply With Quote
Old 12-02-2011, 03:50 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 1
Shinohara is on a distinguished road
Default

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 View Post
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.

Shinohara is offline   Reply With Quote
Reply

Bookmarks

Tags
mutiple uiwindow, uiwindow

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 340
5 members and 335 guests
givensur, ipodphone, jbro, mer10, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:09 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0