How do I intercept tapping of the done button in AVPlayerViewController?

前端 未结 10 739
渐次进展
渐次进展 2021-01-03 22:45

I created an AVPlayerViewController and an attached AVPlayer in the viewDidAppear method of a custom UIViewController. Ho

10条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-03 23:25

    I subclassed AVPlayerViewController and am posting a notification from viewWillDisappear to indicate dismissing of AVPlayerViewController.

    - (void) viewWillDisappear:(BOOL)animated {
        [[NSNotificationCenter defaultCenter] postNotificationName:kPlayerViewDismissedNotification object:nil];
        [super viewWillDisappear:animated];
    }
    

    This might not be 100% correct (as it would fail if you have another view being displayed over AVPlayerViewController), but it worked for me as AVPlayerViewController is always at the top of the stack.

提交回复
热议问题