2010-12-07 6 views
2

iOSシミュレータでUIViewControllerでそのコードをトレースしてテストするときにコンソール出力が表示されない理由を知りたいのですが、デバイス上でテストするだけでトレースします。NSLog InterfaceRotationはシミュレータで動作しませんか?

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 
    NSLog(@"willRotateToInterfaceOrientation: ", toInterfaceOrientation); 
} 

そして、どのように私はUIInterfaceOrientation値(列挙型)ことをプリントアウトしていますか? あなたのお手伝いをすることは素晴らしいことです。お気軽に

答えて

10

フォーマット指定はどこですか?

UIInterfaceOrientationは、オブジェクトではないため、フォーマット指定子として%@を使用することはできません。

は次のようになります。

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 
    NSLog(@"willRotateToInterfaceOrientation: %d", toInterfaceOrientation); 
} 

あなたが本当にが「かわいいプリント」この種の機能が必要な場合は、このように、switchを通してそれを実行することができます。

NSString *orient; 
switch(toInterfaceOrientation) { 
    case UIInterfaceOrientationLandscapeRight: 
     orient = @"UIInterfaceOrientationLandscapeRight"; 
     break; 
    case UIInterfaceOrientationLandscapeLeft: 
     orient = @"UIInterfaceOrientationLandscapeLeft"; 
     break; 
    case UIInterfaceOrientationPortrait: 
     orient = @"UIInterfaceOrientationPortrait"; 
     break; 
    case UIInterfaceOrientationPortraitUpsideDown: 
     orient = @"UIInterfaceOrientationPortraitUpsideDown"; 
     break; 
    default: 
     orient = @"Invalid orientation"; 
} 
NSLog(@"willRotateToInterfaceOrientation: %@", orient); 
+0

ええ、あなたの本当に速い答えに感謝します!そのUIInterfaceOrientation-valueをどのように出力するのですか? – geforce

+0

コードはそれだけです。これは数値です。翻訳のためにドキュメントを照会する必要があります。 – Eiko

+0

@geforce @Elko更新が表示されます。 –

関連する問題