iphone - set Portrait Mode to Landscape -


i tried using category.... add new files , select category , make subclass uinavigationcontroller class.

here code category .h

    #import <uikit/uikit.h>     #import "appdelegate.h"      @interface uinavigationcontroller (orientation)      @end  code .m file  #import "uinavigationcontroller+orientation.h"  @implementation uinavigationcontroller (orientation)  - (bool)shouldautorotate {     return yes; }  - (nsuinteger)supportedinterfaceorientations {      appdelegate * delegate=(appdelegate *)[[uiapplication sharedapplication]delegate];      if (delegate.islandscape)     {         // iphone, return uiinterfaceorientationmaskallbutupsidedown         return uiinterfaceorientationmasklandscape;      }     return uiinterfaceorientationmaskportrait;  } @end 

islandscape declared in app delegate check weather first view controller or secondview controller islandscape bool.

now firstviewcontroller.m file want in portarit mode used code

- (ibaction)playclicked:(id)sender {     appdelegate * delegate=(appdelegate *)[[uiapplication sharedapplication]delegate];       self.navigationcontroller.navigationbarhidden=yes;     delegate.islandscape=yes;      viewcontroller * v=[[viewcontroller alloc]initwithnibname:@"viewcontroller" bundle:nil];      [self presentviewcontroller:v animated:no completion:nil];       //[self dismissviewcontrolleranimated:yes completion:nil];    [self.navigationcontroller pushviewcontroller:v animated:yes];  }   - (nsinteger)supportedinterfaceorientations {     return uiinterfaceorientationmaskportrait; } 

and secondviewcontroller want in landscape mode used one.

delegate.islandscape=no;   // called transfer category   - (nsinteger)supportedinterfaceorientations {     return uiinterfaceorientationmasklandscape; } 

i refer 1st viewcontroller in protrait , secondviewcontroller in landscape mode , landscape apps xcode 5 / ios 7 , other not working me

have @ project on github https://github.com/alloy/forceorientationtest

enter image description here


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -