2017-02-03 3 views
1

내 응용 프로그램에서 Uber와 비슷한 비디오 스플래시 구현을 수행하고 있습니다. 스토리 보드의 하단에 두 개의 버튼을 스토리 보드에 등 간격으로 추가했습니다. 이제 NSBundle에있는 비디오를 재생하기 위해 AVPlayer를 추가하고 있습니다. 응용 프로그램을 실행하는 동안 비디오가 재생되지만 하단에 내 단추가 표시되지 않습니다. 왜 그런가? 제안하십시오 ..스토리 보드에있는 UIButton을 iOS의 AVPlayer 상단에 추가하는 방법은 무엇입니까?

- (void)createVideoPlayer { 

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"welcome_video" ofType:@"mp4"]; 
    NSURL *url = [NSURL fileURLWithPath:filePath]; 

    AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url]; 

    self.player = [AVPlayer playerWithPlayerItem:playerItem]; 
    self.player.volume = PLAYER_VOLUME; 

    AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player]; 
    playerLayer.videoGravity = UIViewContentModeScaleToFill; 
    playerLayer.frame = self.playerView.layer.bounds; 
    [self.playerView.layer addSublayer:playerLayer]; 

    [self.player play]; 

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayDidEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:self.player.currentItem]; 
} 

- (void)moviePlayDidEnd:(NSNotification*)notification{ 

    AVPlayerItem *item = [notification object]; 
    [item seekToTime:kCMTimeZero]; 
    [self.player play]; 
} 

스토리 보드에서 버튼의 스크린 샷 : enter image description here

시뮬레이터의 출력 :의 제약을 : 당신은 버튼을 누락 참고있다 볼 수 있습니다

enter image description here

이 버튼은 정확하고 모든 미리보기에서 볼 수 있습니다 ...

+0

avplayer를 추가 한 후 버튼을 사용하여 'bringSubviewToFront'를 시도해보세요. –

+0

스토리 보드에서 UIButton에이 작업을 수행하는 방법은 무엇입니까? –

+0

그 플레이어의 프레임을 시도하십시오. –

답변

1

Button 콘센트를 앞쪽으로 가져와 에 표시하려면보기에 AVPlyer 인스턴스를 추가 한 후 bringSubviewToFront으로 전화해야합니다.

[self.view bringSubviewToFront:buttonOutlet]; 
1

avplayer를 추가 한 후에 버튼에서 bringSubviewToFront를 호출 해 볼 수 있습니다.

관련 문제