Unable to resize UIWindow

I am trying to add a new window on top of my current iPad application, but I can’t understand why it is always full screen. I am 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 a full screen window. Please advise, thanks.

+6
source share
2 answers

IOS applications must have only one UIWindow object.

you should probably set the frame in the UIView viewController and add it as a subtitle.

-16
source

To change the frame of another added UIWindow, you must launch your window with the desired frame:

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

Set property bindings to objects:

 [self.myNewWindow setClipsToBounds:YES]; 

And then, by installing rootViewController in a new window, also set its frame:

 self.myNewWindow.rootViewController = self.fooViewController; [self.myNewWindow makeKeyAndVisible]; self.fooViewController.view.frame = CGRectMake(0, 0, 300, 440); 

It works on iPhone and iPad.

+11
source

Source: https://habr.com/ru/post/901472/


All Articles