PhoneGap 2.1 iPad no longer autorotates on iOS 6

When I launch the app on iOS 6, my app no โ€‹โ€‹longer successfully autorotates. I upgraded to Cordoba 2.1, and I have the following code in my MainViewController.m file (which is a subclass of CDViewController , to be compatible with the new iOS6 way to handle autorotation:

 - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation]; } // iOS 6 - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { NSUInteger ret = 0; if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait]) ret = ret | (1 << UIInterfaceOrientationPortrait); if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown]) ret = ret | (1 << UIInterfaceOrientationPortraitUpsideDown); if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight]) ret = ret | (1 << UIInterfaceOrientationLandscapeRight); if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft]) ret = ret | (1 << UIInterfaceOrientationLandscapeLeft); return ret; } 
+4
source share
3 answers

In the AppDelegate.m application, you need to add the following: didFinishLaunchingWithOptions

 [self.window setRootViewController:self.viewController]; 

Once you add this, the rotation should start working again. It has for my two applications.

+8
source

Still too new to be able to vote for a matte answer in this thread. However, I would like to repeat his answer and, to add value, note that his proposed fix also works for PhoneGap / Cordova 1.9

I have several applications that have not yet gone through the PhoneGap / Cordova 1.9 โ†’ 2.0 / 2.1 update process, and manually making the changes suggested above in AppDelegate.m worked for these applications.

Also, it's worth adding that when you put this line, it seems to matter.

I initially added this line just before: return YES, and it failed. Turns out you need to put it before this line:

 [self.window addSubview:self.viewController.view]; 

One more thing .... help google / etc. find this problem faster ... the key clue in the console log that you need to add this line is the following:

It is expected that the root controller will be installed in the application windows at the end of the application launch

Adding the line of code mentioned above makes this error go away ...

Hope this helps others see this issue.

+4
source

I had a similar problem with my iPad application on iOS 6. This problem occurs because the MainViewController is not configured for rootViewController in AppDelegate.m . In AppDelegate.m replace:

 [self.window addSubview:self.viewController.view]; 

with

 self.window.rootViewController = self.viewController; 
+1
source

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


All Articles