2017-10-22 4 views
1

아마도 이것이 중복 된 질문이지만, 이미 존재하는 질문에는 해결책이 없었기 때문에 다시 현상금 문제를 시작할 수있게 다시 요청할 것입니다. 여기 AVPlayer iOS 11에서 맞춤 검색 버튼이 작동하지 않지만 iOS 11에서 완벽하게 작동합니까?

는 아이폰 OS (11) 아래에 노력하고 있습니다 내 코드입니다 :

AVPlayer *player = [AVPlayer playerWithURL:videoURL]; 

// create a player view controller 
avcontroller = [[AVPlayerViewController alloc]init]; 
avcontroller.player = player; 
[player play]; 


NSNotificationCenter *noteCenter = [NSNotificationCenter defaultCenter]; 
[noteCenter addObserverForName:AVPlayerItemDidPlayToEndTimeNotification 
         object:nil 
         queue:nil 
        usingBlock:^(NSNotification *note) { 

         NSLog(@"Video end"); 
         self.avcontroller.player = nil; 
         [self.avcontroller.view removeFromSuperview]; 
         [self.view addSubview:delegate.tabViewControllerObj.tabBarController.view]; 
        }]; 

_skip =[UIButton buttonWithType:UIButtonTypeCustom]; 
[_skip addTarget:self action:@selector(btnSkipTapped) 
forControlEvents:UIControlEventTouchUpInside]; 
[_skip setTitle:@"Skip" forState:UIControlStateNormal]; 
_skip.layer.borderWidth = 2.0f; 
_skip.layer.cornerRadius = 12; 
_skip.clipsToBounds = YES; 
_skip.layer.borderColor = [UIColor whiteColor].CGColor; 

// show the view controller 
[self addChildViewController:avcontroller]; 
[avcontroller.view addSubview:_skip]; 
[avcontroller.view bringSubviewToFront:_skip]; 
[self.view addSubview:avcontroller.view]; 
avcontroller.view.frame = self.view.frame; 

} 

-(void)viewDidLayoutSubviews{ 
    [super viewDidLayoutSubviews]; 

_skip.frame = CGRectMake((self.view.frame.size.width-140),(self.view.frame.size.height-150),100.0,35.0); 
} 

을 그리고 여기에 버튼 탭 기능입니다 :

- (IBAction)btnSkipTapped{ 

NSLog(@"Skip button clicked"); 
self.avcontroller.player = nil; 
[self.avcontroller.view removeFromSuperview]; 
[self.view addSubview:delegate.tabViewControllerObj.tabBarController.view]; 
} 
이 코드는 완벽하지만, 버튼 탭에 버튼이 표시됩니다

, 그것은 'didn를 btnSkipTapped 함수를 호출하십시오. 도움이 될 것입니다.

답변

3

@DeepShah avcontroller.view에 건너 뛰기 단추를 추가 했으므로 표시가 적절하지만 표시 할 수 없습니다. AVPlayerViewControllerContentView은 건너 뛰기 버튼을 포함하고 있기 때문에 클릭 할 수 없습니다.

는 이미지 아래 참조 :

image

그래서 당신이 self.view과 그 작품에 스킵 버튼을 추가해야합니다.

[self.view addSubview:_skip]; 
[self.view bringSubviewToFront:_skip]; 
+0

고맙습니다. 그것은 완벽하게 작동했습니다. –

+0

내 문제는 똑같은 문제에 직면한다. AVPlayerViewController를 표시하고 사용자 정의 button.A 버튼을 추가하는 것은 AVPlayerViewController에 표시되지만 버튼 액션을 트리거 할 수는 없다. 위에서 언급 한 것을 시도했지만 작동하지 않았다.이 문제는 ?있는 UIButton self.playerViewController.view 등 (.custom 형) .addSubview (BTN) self.playerViewController.view .bringSubview (toFront : self.castWrapperView) 자기 iOS 만 11 하자 BTN =있는 UIButton 발생한 .present (self.playerViewController, animated : false, 완료 : nil) @Nirav이 문제에 대한 아이디어가 있습니까? – PramukaD

+0

가'self.view' 또는'self.playerViewController.view'에 추가 되었습니까? –

관련 문제