Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't change the size of a UIWindow

I'm trying to add a new window on top of my current one, on an iPad application, but I can't figure out why it always presents itself as fullscreen. I'm using this code:

UIWindow *window = [[UIWindow alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];


[window setFrame:CGRectMake(0, 0, 20, 20)];
ArrowController *controller = [[ArrowController alloc]initWithNibName:@"ArrowController" bundle:nil];   

[window setRootViewController:controller];    
[window setHidden:NO];

[controller release];

No matter what size I set on its frame I always get presented with a full screen sized window. Please advise, thank you.

like image 584
the Reverend Avatar asked Nov 14 '11 23:11

the Reverend


1 Answers

To change the frame of another UIWindow you add, you have to init your window with the frame you want:

self.myNewWindow = [[UIWindow alloc] initWithFrame:CGRectMake(10, 10+20, 300, 440)];

Set its property clips to bounds to active:

[self.myNewWindow setClipsToBounds:YES];

And then after setting your rootViewController to the new window, set its frame too:

self.myNewWindow.rootViewController = self.fooViewController;
[self.myNewWindow makeKeyAndVisible];

self.fooViewController.view.frame = CGRectMake(0, 0, 300, 440);

This is working on iPhone and iPad.

like image 81
Ludovic Landry Avatar answered Oct 16 '22 15:10

Ludovic Landry