0
votes

I am running a test program with a sample view controller . In my app delegate , I have the following

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
NSLog(@"window frame %@",NSStringFromCGRect(self.window.frame));
}

The output is window frame {{0, 0}, {768, 1024}}. I have the device in lanscape mode but the window frame returns a swapped value of width and height .

I am not able to place my view components using hard coded values because of this . Any clues what is going wrong.

1

1 Answers

2
votes

You are trying to get the size of the view before this function is called...

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

This only gets called after

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

exits. Is there a reason you need to do it inside of this function? I would try doing it inside of your UIViewControllers viewDidLoad function instead.

Hope this helps :)