2012-08-30 3 views

답변

0

비디오가있는 UIWebView에서 재생하면 동영상이 재생되고 완료되면 버튼을 사용하여 웹보기에 URL을로드하는 데 사용했던 코드와 함께 다음과 같은 코드를 사용하여 눌렀을 때 다음에 액세스 할 수 있습니다

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

그리고 이 마지막 난 완료 버튼 동작에 대한 해결책을 발견

BOOL isVideoInFullScreenMode;//Temperory added here.. must be in .h file or at teh top if required 
-(void)videoPlayStarted:(NSNotification *)notification{ 
//Your stuff here 
    isVideoInFullScreenMode = YES; 
} 

-(void)videoPlayFinished:(NSNotification *)notification{ 
    //Your stuffs here 
    isVideoInFullScreenMode = NO; 
} 
0

통해 액세스 할 수 ...이 논리 & 아이폰도 모두 아이 패드 작동 .. 난 UIGestureRecognizer를 사용하여 확률값을 해결했다.

여기 내 코드입니다.

우선 내가 ..

-(void)youTubeStarted:(NSNotification *)notification{ 
if (!tapRecognizer1) { 
    tapRecognizer1 = [[UITapGestureRecognizer alloc] init]; 
    tapRecognizer1.delegate = self; 
    [tapRecognizer1 setNumberOfTapsRequired:1]; 
    [self.view addGestureRecognizer:tapRecognizer1]; 
}  
} 

이것은 movieplayer에 TapRecognizer를 추가합니다 ..이 코드를 추가 youTubeStarted 방법 지금

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

를 사용하여 EnterFullScreen에 대한 알림을 추가하고

그리고 이제 다음 대리자 메서드는 버튼이 완료되었는지 확인합니다.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ 
NSLog(@"%@",touch.description); 
NSString *ViewName = touch.description ; 
CGPoint location = [touch locationInView:touch.view]; 
NSLog(@"location x===%f , location y=== %f",location.x,location.y); 
NSRange Check = [ViewName rangeOfString:@"UINavigationButton"]; 
NSRange checkFrameOfButton; 
if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) { 
    checkFrameOfButton = [ViewName rangeOfString:@"frame = (7 7; 50 30)"]; 
    if (checkFrameOfButton.length <= 0) { 
     checkFrameOfButton = [ViewName rangeOfString:@"frame = (7 7; 51 30)"]; 
    } 
} 
else { 
    checkFrameOfButton = [ViewName rangeOfString:@"frame = (5 7; 48 30)"]; 
    if (Check.length<=0) { 
     Check = [ViewName rangeOfString:@"UIView"]; 
    } 
} 
if (location.y<40 && location.x<85 && Check.length>0 && checkFrameOfButton.length>0) { 
    [self endplaying]; 
    } 
    return YES; 
} 

이제는 endplaying 방법으로 원하는 것을 할 수 있습니다.

관련 문제