1

I have an app that is designed to run in portrait and all is well. However I have implemented Mobfox's vAds which require landscape mode.

At present I get the following error when the vAD is called

2013-01-08 23:44:05.109 Tv - IOS[1422:907] mobfox video did load
2013-01-08 23:44:05.125 Tv - IOS[1422:907] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

So the im thinking the fix would be allow for landscape in the app.

I need to force the app to run in portrait but allow for landscape when the vAd is called

So just to recap:

I need Portrait only orientation during normal app view and landscape/portrait during the mobFox vAd view is visible.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Tom
  • 2,358
  • 1
  • 15
  • 30

2 Answers2

4

Return NO for shouldAutorotate:

-(BOOL)shouldAutorotate {
  return NO;
}

Or if it is YES you need to return the supportedInterfaceOrientations (at least one), here its only allowing portrait:

- (NSUInteger)supportedInterfaceOrientations{
  return UIInterfaceOrientationMaskPortrait;
  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
      return UIInterfaceOrientationMaskAll;
  }
}
Sverrisson
  • 17,970
  • 5
  • 66
  • 62
  • Actually the code allows no rotation when returning 'NO'. Try that. Otherwise return 'YES' and 'UIInterfaceOrientationMaskAllButUpsideDown' – Sverrisson Jan 09 '13 at 00:01
  • The code provided is overrided by mobfox's vAd and i get the following error code 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES' – Tom Jan 09 '13 at 00:03
  • The error message says that you are returning YES from shouldAutorotate. So, you have not changed the code as above. Not these methods should be in your root controller! – Sverrisson Jan 09 '13 at 00:06
  • the methods are in the rootView controller and i have deffo put what you suggest. It is a strange one. This is why im thinking the the Mobfox vAd is overwriting the ShouldAutorotate method in the rootview controller – Tom Jan 09 '13 at 00:12
  • Then try setting it to 'YES' and returning 'UIInterfaceOrientationMaskAllButUpsideDown' – Sverrisson Jan 09 '13 at 00:13
  • Same Problem Hannes, But thanks for trying to help :) It looks like this guy had the same problem https://groups.google.com/forum/#!msg/google-admob-ads-sdk/_kQhG05vISk/BSrTlkRAUOoJ – Tom Jan 09 '13 at 00:17
  • @user1922242 Please accept the answer if you have a conclusion. – Sverrisson Jan 09 '13 at 11:12
-1

Ok, after sleeping on this i managed to finally resolve the problem.

Solution: I had to subclass UINavigationController and override the autorotation methods and allow all rotations in in project > Target > summary settings

- (BOOL)shouldAutorotate {
return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
// pre-iOS 6 support 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
Tom
  • 2,358
  • 1
  • 15
  • 30
  • You strip me of my answer and then adds an identical answer and gives it your vote! Please explain. – Sverrisson Jan 22 '13 at 15:58
  • I didn't realise I did this I am so sorry, I have restored it to its original. Please accept my apologies. – Tom Jan 22 '13 at 22:16