2011-11-28 39 views
1

我在UIViewController中創建了一個UIWebView。這個網頁視圖包含一個像這樣的YouTube視頻頁面:http://www.youtube.com/watch?v=oL1RE8JXaIwYoutube視頻強制iOS應用程序旋轉

當我點擊視頻鏈接時,iOS視頻播放器啓動。一切都很順利,直到這裏。

問題是,當我旋轉我的應用程序(在橫向模式下),然後單擊完成按鈕時,View Controller處於橫向模式。

所以我在視圖控制器中添加這個回調:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    return NO; 
} 

,但一切都沒有改變。

有什麼想法?

回答

1

該方向代碼無效 - 請務必至少在一個方向上返回YES

0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    return UIInterfaceOrientationPortrait; 
} 
0

我經手的viewDidLoad方法

[[NSNotificationCenter defaultCenter] addObserver:self 
            selector:@selector(moviePlayerDidExitFullScreen) 
             name:@"UIMoviePlayerControllerDidExitFullscreenNotification" 
             object:nil]; 

使用NSNotification這樣那樣的問題,這方法將調用視頻結束時,你可以做必要的修改

- (void)moviePlayerDidExitFullScreen 
{ 
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 

    if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight || orientation == UIInterfaceOrientationPortraitUpsideDown) 
    { 
     [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait]; 
    } 
} 

希望幫助

相關問題