2011-01-18 5 views
0

私は過去にこれを行うことができました。そこでは、特定のビューを開き、シミュレータが左に曲がり、その後に再びポートレートに戻ります。Obj-C、iphoneシミュレータをランドスケープにするにはどうすればいいですか?

私は景色を見ることができますが、私はそれを見るために頭を回転させる必要があります。

私はMoriatry piechartを試しています。

私が試したものを相続人viewWillAppear

CGRect myImageRect = CGRectMake(0.0f, 20.0f, 460.0f, 280.0f); 
BNPieChart* chart = [[BNPieChart alloc] initWithFrame:myImageRect]; 
[chart addSlicePortion:0.1 withName:@"Orange 10%"]; 
[chart addSlicePortion:0.2 withName:@"Fandango 10%"]; 
[chart addSlicePortion:0.1 withName:@"Blue 10%"]; 
[chart addSlicePortion:0.1 withName:@"Cerulean 10%"]; 
[chart addSlicePortion:0.3 withName:@"Green 10%"]; 
[chart addSlicePortion:0.1 withName:@"Yellow 10%"]; 
[chart addSlicePortion:0.1 withName:@"Pink 10%"]; 
[self.view addSubview:chart]; 

で私が使用しているコードは、これらの....おそらく、私はそれらを正しく使用していないされています?シミュレータのiOSで

PieChartViewController *nextController = [[[PieChartViewController alloc] 
    initWithNibName:@"PieChartView" bundle:nil] autorelease]; 
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] 
    delegate]; 

CGAffineTransform newTransform = 
    CGAffineTransformMake(0.0,1.0,-1.0,0.0,0.0,0.0);   
nextController.view.transform = newTransform; 
[nextController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; 

[delegate.graphNavController pushViewController:nextController animated:YES]; 

そして、この..

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

そして...

- (void)viewDidLoad { 
[super viewDidLoad]; 

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
[[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(didRotate:) 
    name:@"UIDeviceOrientationDidChangeNotification" 
    object:nil];  
} 

- (void) didRotate:(NSNotification *)notification { 
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 

    if (orientation == UIDeviceOrientationLandscapeLeft || 
    orientation == UIDeviceOrientationLandscapeRight) { 
    return; 
    } 

} 
+2

シミュレータを回転するには、cmd +→およびcmd +←キーの組み合わせを使用します。 – Jasarien

+0

はい、でもコードで行うことができます。私は持っていますが、もう一度それを適用することはできません。 – Jules

+0

できれば驚いています。なぜあなたはしたいのですか? – gef

答えて

0

アプリ/ビューがランドスケープでのみ実行されるように設定されている場合、シミュレータは自動的にランドスケープに切り替わります。 (また、plistファイルでサポートされているインターフェイスの向きを設定する必要があります)。

アプリがすべての向きをサポートしている場合は、メニュー/キーコマンドを使用してそれを回転させる必要があります。

+0

私はこれをテストアプリケーションで動かしています。あなたがする必要があるのは、 'shouldAutorotateToInterfaceOrientation'を' LandscapeRight'に変更するだけです。テンプレートに追加されたものだけで、簡単なナビゲーションバーのアプリにある。しかし、私のアプリでは、私はメインウィンドウにはないが、まだプッシュされているビューを持っています。ビューはランドスケープになっていますが、シミュレータには移動しません。 – Jules

1

、(右に回して)左にメニューウェア、回転させるために行きます!

関連する問題