2011-11-15 2 views
1

편집 : 동영상은 사용중인 앱, 즉 세로 모드로 재생하도록 설계된 교육용 동영상입니다. UIWebView에서 YouTube 동영상을 재생할 때 세로 모드가 강제로 적용됩니다.

나는 (너무 조심, NB iPhoneDevSDK.com 현재 악성 코드를 포함하는 것으로 구글로 표시됩니다. 나는 screengrab of the relevant post 업로드 한) this method사용 &는 YouTube 동영상 (장면 뒤에있는 UIWebView를 사용하여) 재생 열을.

내가 보여주고 자하는 비디오는 세로로 녹화 (320x480으로 업로드)되었으며 세로 모드에서 아이폰 화면을 멋지게 채우기위한 것입니다. 그러나 YouTube 동영상은 강제 가로 모드에서 시작되며 휴대 전화를 가로보기 위치로 이동 한 다음 다시 (때때로 몇 번해야하는 경우) 인물 사진에만 넣을 수 있습니다.

내가 궁금한 점은 UIWebView에서 세로 모드로 기본 설정된 비디오 플레이어를 열도록 강요하는 방법이 있습니까?

NB UIWebView를 생성하는 UIWebView 대리인에 (interfaceOrientation == UIInterfaceOrientationPortrait)를 설정했습니다.

편집 : 난이 작동 얻을 것이라는 오프 기회에있는 UIWebView를 서브 클래스 시도 :

@interface AltWebView : UIWebView 
@end 

@implementation AltWebView 

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

@end 
  • 첫 번째 이미지 : 세로 모드 : 기본
  • 두 번째 이미지로 풍경에서 재생 비디오 한 번에 몇 번

In Landscape by default In Portrait mode once rotated a few times

회전

답변

1

UIWebView를 소유 한보기 컨트롤러의 경우보기 컨트롤러의 모든 것을 세로 모드로만 표시하도록 지정할 수 있습니다.

뭔가 등이 말 :

- (void)viewWillAppear:(BOOL)animated { 
    [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait]; 
} 

및 BTW

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

, 도움이되는 힌트 많은 도움이 질문에 이상있다 : iPhone SDK: Orientation (Landscape and Portrait views)

+0

제안 해 주셔서 감사합니다. 저는이 두 가지를 모두 시도했지만 여전히 불행히도 풍경 모드에서 동영상을 시작합니다. –

+0

다음과 같은 경우를 대비하여 UIWebView를 서브 클래 싱하려고했습니다. * 편집 : 볼 여기에 코드를 입력 할 수 없습니다. 메인 포스트를보십시오. –

+0

두 가지 방법은 뷰 컨트롤러가 아닌 뷰입니다. 심지어 전화 받기. :-) 당신이해야 할 일은 두 가지 방법으로 새로운보기 컨트롤러를 만들고 UIWebView를 xib 파일에 넣은 다음 보여줄 동영상이있을 때보기 컨트롤러를 밀거나 선물하십시오. 말이된다? –

4

내가 같은 문제에 직면했습니다 최근에이 코드를 사용했습니다. 이것은 귀하의 질문에 대한 올바른 대답이 아니지만 YouTube 동영상을 세로 모드로 재생합니다.

NSString *embedHTML = @"<iframe title=\"YouTube video player\" width=\"320\" height=\"460\" scrolling=\"no\" src=\"http://www.youtube.com/embed/%@?modestbranding=1&amp;rel=0;autoplay=1;showinfo=0;loop=1;autohide=1\" frameborder=\"0\" allowfullscreen allowTransparency=\"true\"></iframe>"; 

NSString *htmlStr = [NSString stringWithFormat:embedHTML, videoID]; // videoID is like EgXdUs9HsrQ... 

[webView loadHTMLString:htmlStr baseURL:nil]; 
+0

그게 좋은 생각인데, 그걸 시도해 볼게. 감사. –

관련 문제