내 응용 프로그램에서 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];
}
시뮬레이터의 출력 :의 제약을 : 당신은 버튼을 누락 참고있다 볼 수 있습니다
이 버튼은 정확하고 모든 미리보기에서 볼 수 있습니다 ...
avplayer를 추가 한 후 버튼을 사용하여 'bringSubviewToFront'를 시도해보세요. –
스토리 보드에서 UIButton에이 작업을 수행하는 방법은 무엇입니까? –
그 플레이어의 프레임을 시도하십시오. –