私はこの問題を、私は理解できないということを構築しているアプリケーションで持っています。 私のアプリケーションは、以下の構造を有する:UIWebViewの埋め込みビデオを回転させる方法
UITabBarController - >のUIViewController - >のUIViewController
最後のビューコントローラは、ページ全体をロードするのUIWebViewが含まれています。そのページには大きな丸い再生ボタンを押すとユーザーが再生できるムービー(mp4)があります。
アプリケーションはポートレートモードで動作するように作られており、初期設計のために実行できない方法はありません。
私が達成したいのは、ムービーが再生を開始し、それに応じてムービーを回転させると、ユーザーが携帯電話を回転できるようにすることです。 NSNotificationsCenterが送信するさまざまなNSNotificationを聞いて映画が再生されるとき、私は '検出'することができました。
私は開始を検出するためにこれを使用する:終了を検出するための
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieIsPlaying:)
name:@"UIMoviePlayerControllerDidEnterFullscreenNotification"
object:nil];
と、この:今私は1つのグローバルYESに変数または私ができるNOウィッヒを設定する2つのセレクタ付き
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieStopedPlaying:)
name:@"UIMoviePlayerControllerDidExitFullscreenNotification"
object:nil];
後で使用する
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
上記のメソッドから常にYESを返すと、ムービーが起動して動作している場合を除いて常時スクリーンに表示されます。最も奇妙なことはこれです:
- 私は肖像画でアプリケーションを開きます。
- 目的のページに移動します(上記の私の構造を参照)
- が(インタフェースが回転する - これは単なるデバッグ用です)風景に電話を回して(!それは風景の中に起動Horray!)私は映画を開始
- 私は私が映画を起動した場合、私はまた戻って風景に(これ以上の回転が発生していない...)
電話を回転させる
何とかお手伝いできることがありましたら教えてください。私は本当に必死です。それ以上の情報が必要な場合は、私に知らせてください。
ありがとうございます!
私は上記の2つの方法については、このソリューションを作ってみた最後に更新
:
- (void)movieIsPlaying:(NSNotification *)notification
{
if (![Globals canRotateInterface]) {
[Globals setCanRotateInterface:YES];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[[[[notification object] view] window] setBounds:CGRectMake(0, 0, 480, 320)];
[[[[notification object] view] window] setCenter:CGPointMake(160, 240)];
[[[[notification object] view] window] setTransform:CGAffineTransformMakeRotation(M_PI/2)];
}
}
- (void)movieStopedPlaying:(NSNotification *)notification
{
if ([Globals canRotateInterface]) {
[Globals setCanRotateInterface:NO];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
[[[[notification object] view] window] setBounds:CGRectMake(0, 0, 320, 480)];
[[[[notification object] view] window] setTransform:CGAffineTransformIdentity];
// Little hack to force an orientation rotation so that all elements get their original size and place (eg. Navigation bar)
UINavigationController *dummyNavigationViewController = [[UINavigationController alloc] init];
[self presentModalViewController:dummyNavigationViewController animated:NO];
[self dismissModalViewControllerAnimated:NO];
[dummyNavigationViewController release];
}
}
これはiOS 4.3でのみ動作します – jorjap
iOS 6でどのように再生できますか? –