1

この行で:[self deviceInterfaceOrientationChanged:interfaceOrientation];

この警告が表示されます

Implicit conversion from enumeration type ' UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'?

私を助けてくれませんか?お願いします。ありがとう

コードは次のとおりです。

     -(void) receivedRotate: (NSNotification*) 通知
{
    NSLog(@"receivedRotate");
    UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] 方向];

    if(interfaceOrientation != UIDeviceOrientationUnknown) {
        [self deviceInterfaceOrientationChanged:interfaceOrientation];


    } そうしないと {
        NSLog(@"不明なデバイスの向き");
    }
}
4

1 に答える 1

0

UIDeviceOrientation と UIInterfaceOrientation は異なるタイプです。1 つ目はデバイスの向きで、Face up や Face Down などの他の状態が含まれますが、2 つ目は Portrait や Landscape などの 2D 状態のみをカバーします。

デバイスからではなく、次のようなステータス バーからデバイスの向きを取得します。

[[UIApplication sharedApplication] statusBarOrientation] 

このメソッドは UIInterfaceOrientation 値を返し、問題は解消されます。

于 2014-11-18T20:02:56.027 に答える