2011-12-20 9 views
0

私はウェブサーバーからビデオを再生するアプリケーションを持っていましたが、それは横向きに再生されます。私は自分のアプリが加速度計を使ってビデオを風景や縦書きで再生したいと思っています。動画再生機能をiPhoneのYouTubeアプリのように見せたい誰も私にこれを行う方法を手伝ってもらえますか?ありがとうムービープレイヤーのアプリケーションで加速度センサーを使用

答えて

1

これは加速度計を必要としません。代わりに、オリエンテーションが変更されたときに送信されるUIDeviceシングルトンインスタンスからの通知を待ち受けます。あなたの "アプリケーションdidFinishLaunching withOptions" 方法では、このように入力します。

- (void)deviceOrientationDidChange { 
int orientation = (int)[[UIDevice currentDevice]orientation]; 
switch (orientation) { 
    case UIDeviceOrientationFaceDown: 
     NSLog(@"UIDeviceOrientationFaceDown"); 
     // handle orientation 
     break; 
    case UIDeviceOrientationFaceUp: 
     NSLog(@"UIDeviceOrientationFaceUp"); 
     // handle orientation 
     break; 
    case UIDeviceOrientationLandscapeLeft: 
     NSLog(@"UIDeviceOrientationLandscapeLeft"); 
     // handle orientation 
     break; 
    case UIDeviceOrientationLandscapeRight: 
     NSLog(@"UIDeviceOrientationLandscapeRight"); 
     // handle orientation 
     break; 
    case UIDeviceOrientationPortrait: 
     NSLog(@"UIDeviceOrientationPortrait"); 
     // handle orientation 
     break; 
    case UIDeviceOrientationPortraitUpsideDown: 
     NSLog(@"UIDeviceOrientationPortraitUpsideDown"); 
     // handle orientation 
     break; 
    case UIDeviceOrientationUnknown: 
     NSLog(@"UIDeviceOrientationUnknown"); 
     // handle orientation 
     break; 

    default: 
     break; 
} 
} 

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

は、姿勢の変化を処理するために、このメソッドを作成します

関連する問題