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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With