ios - Change camera and device orientation -


i have application view , when user click button, camera visualization starts.

i want allow orientations when camera isn't showed, when camera showed, need force application portrait mode because if isn't on portrait, video rotated. when camera closed, app may rotate again.

do know if can solve problem video orientation?

or how can force app portrait mode? know on earlier ios version, can use [uidevice setorientation:], it's deprecated lastest ios.

how can ios 5 , ios 6?

i've tried with:

[self presentviewcontroller:[uiviewcontroller new] animated:no  completion:^{ [self dismissviewcontrolleranimated:no completion:nil]; }];  

and in shouldautorotatetointerfaceorientation method:

if (state == camera) {         return (interfaceorientation == uiinterfaceorientationportrait);     }else{         return yes; } 

it works ok , force app portrait. when camera closed, doesn't work properly, doesn't rotate well.

i mean, when camera closed happens:

  • the app on portrait
  • if try rotate app, device rotated not application. can see status bar of ipad info time, battery, etc rotated app not.
  • if go portrait again , rotate device, works ok.

do know problem?

thanks in advance.

i think i've found solution problem change camera , device orientation @ same time.

i call code when initialize camera, , in shouldautorotatetointerfaceorientation method, allow orientations.

 avcapturevideoorientation neworientation;      uiinterfaceorientation deviceorientation = [uiapplication sharedapplication].statusbarorientation;      nslog(@"deviceorientation %c",deviceorientation);      switch (deviceorientation)     {         case uiinterfaceorientationportrait:             nslog(@"uiinterfaceorientationportrait");             neworientation = avcapturevideoorientationportrait;             break;         case uiinterfaceorientationlandscaperight:             nslog(@"uiinterfaceorientationlandscaperight");             neworientation = avcapturevideoorientationlandscaperight;             break;         case uiinterfaceorientationlandscapeleft:             nslog(@"uiinterfaceorientationlandscapeleft");             neworientation = avcapturevideoorientationlandscapeleft;             break;         default:             nslog(@"default");             neworientation = avcapturevideoorientationportrait;             break;     }      if ([self.prevlayer respondstoselector:@selector(connection)]){         if ([self.prevlayer.connection isvideoorientationsupported]){             self.prevlayer.connection.videoorientation = neworientation;         }else{             nslog(@"no respond selector connection");         }     }else{   if ([self.prevlayer isorientationsupported]){         self.prevlayer.orientation = neworientation;     }else{         nslog(@"no isorientationsupported");     }  } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -