2011-11-11 14 views
0

私はIphoneに電卓の画面を持っています。私はそれを肖像画で表示しましたが、私は肖像画から風景モードで電卓の画面を表示したいと思います。風景モードでポートレートで表示する方法は?

私はソースコードを試してみました:

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

をいずれかが私を助けて、肖像画にのみ風景モードを立ち上げた最初の時間を使用しますが、動作していない向きを変更されます。

+0

私はあなたが両方の向きでアプリケーションを実行したいと思います... .. mi right ..それ以外の場合は、正確に何をしたいのか教えてください。..... –

答えて

1

これを試してみてください:ここ

[[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

私はこれらのコードを使用して、ポートレートモードで風景を起動しましたが、 – 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

same question

私のサンドボックスアプリ: https://github.com/comonitos/programatical_device_orientation

ソリューションは簡単です:

インターフェースで(Hファイル):

BOOL rotated; 

実施中(Mファイル): 1.リライト

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

2コール[自己設定]

-(void) setup { 
    rotated = YES; 
    [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft]; 
    rotated = NO; 
    } 
関連する問題