2011-11-11 5 views
0

J'ai un écran de calculatrice dans Iphone, quand je l'ai lancé affiché en portrait, mais je veux afficher l'écran de la calculatrice en mode paysage de portrait et aussi changer l'orientation, comment?Comment afficher en mode paysage en mode portrait?

J'ai essayé le code source:

 self.view.transform = CGAffineTransformIdentity; 
     self.view.transform = CGAffineTransformMakeRotation((M_PI * (90)/180.0)); 
     self.view.bounds = CGRectMake(0.0, 0.0, 480, 320); 

Il est utilisé première fois lancé uniquement en mode paysage en mode portrait, mais changer l'orientation ne fonctionne pas, quelqu'un me aider.

+0

Je pense que vous voulez exécuter votre application à la fois l'orientation ... .. mi droit .. sinon s'il vous plaît dites-moi ce que vous voulez exactement faire ..... –

Répondre

1

Essayez ceci:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; 
[[self view] setBounds:CGRectMake(0, 0, 480, 320)]; 
[[self view] setCenter:CGPointMake(160, 240)]; 
[[self view] setTransform:CGAffineTransformMakeRotation(M_PI/2)]; 
+0

J'utilise ce code, il a été lancé paysage en mode portrait, mais changer l'orientation ne fonctionne pas, merci – sankar

1
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
    { 
     return YES 
    } 

Now make use of any one method for ur rotation 
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; 
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; 
    Hope this help. 
0

L'same question ici

Mon application sandbox: https://github.com/comonitos/programatical_device_orientation

La solution est simple:

dans l'interface (fichier h):

BOOL rotated; 

mise en œuvre (fichier m): 1. rewrite

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

2 appel [Configuration auto]

-(void) setup { 
    rotated = YES; 
    [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft]; 
    rotated = NO; 
    } 
Questions connexes