3

Can anyone explain me what's going on? I use this method

- (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
 {     
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
 }

to provide landscape orientation for the matchmakerViewController. It works perfectly on iPhone and even on iPad simulator but not on iPad device. When i run the application on iPad matchmakerViewController misteriously appear in the portrait orientation. What's wrong? How do i fix it? Thanks

Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161

4 Answers4

3

Change your shouldAutorotateToInterfaceOrientation like

-(BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
 {     
     return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
 }

Also check your application plist file, there will be a key like Supported Interface Orientations it's type will be array and will have 4 values. Delete the portrait modes from the plist and save it. It will work. Please check this.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • @AndreyChernukha: did you check parent view controller's shouldAutorotateToInterfaceOrientation: method ? Is it same as return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); ? – Midhun MP Jun 18 '12 at 16:19
  • i did. it's different. if i make it return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); it starts displaying in portrait mode – Andrey Chernukha Jun 19 '12 at 11:15
  • @AndreyChernukha: is your full application is working on landscape mode or only this view is set to landscape ? – Midhun MP Jun 19 '12 at 16:24
  • all the application is landscape – Andrey Chernukha Jun 20 '12 at 09:03
  • Please return 'NO' from the shouldAutorotateToInterfaceOrientation method. And check is the view rotates. Also add the [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; in your application delegates applicationDidFinishLoading Method. Check and update I'll help you. – Midhun MP Jun 20 '12 at 17:19
  • Also check that your matchmakerViewController is a subclass of UIViewController. – Midhun MP Jun 20 '12 at 18:43
1

(This is most likely not your problem, but I use the following code and it works fine)

return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
interfaceOrientation == UIInterfaceOrientationLandscapeRight)

Additionally, make sure the parent view is set to autorotate true. shouldAutorotateToInterfaceOrientation doesn't work

Community
  • 1
  • 1
Tom
  • 1,330
  • 11
  • 21
1

Here is the elegant solution through Categories, extend the GKMatchMakerViewController, the same solution will work on any other game center view such as leader board views and achievement views:

.h file

#import <Foundation/Foundation.h>
#import "GameKit/GameKit.h"

@interface GKMatchmakerViewController(LandscapeOnly)



-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;

@end

.m file

#import "GKMatchmakerViewController-Landscape.h"

@implementation GKMatchmakerViewController(LandscapeOnly)


-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

   return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);


}

@end

Let me know if it works!!

Kaan Dedeoglu
  • 14,765
  • 5
  • 40
  • 41
0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}


also check parent controller maybe some controller return YES

or try 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    if (interfaceOrientation==UIInterfaceOrientationPortrait)
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    else 
        return NO;
}
Denis
  • 21
  • 1
  • or try exchange (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) to (interfaceOrientation == UIDeviceOrientationPortrait) – Denis Jun 19 '12 at 10:48