Coming soon - Get a detailed view of why an account is flagged as spam!
view details
18
Is it possible to use AVPlayerViewController with iOS 13's context menus?
Post Body

If I implement the delegate method to return a view controller for iOS 13's context menus:

swift func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { return UIContextMenuConfiguration(identifier: nil, previewProvider: { () -> UIViewController? in let videoURL = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")! let player = AVPlayer(url: videoURL) let playerViewController = AVPlayerViewController() playerViewController.player = player return playerViewController } ... }

I get the following error:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This UITargetedPreview initializer requires that the view is in a window, but it is not. Either fix that, or use the other initializer that takes a target.

From what I can gather with view inspection AVPlayerViewController doesn't do anything weird with separate windows, it's part of the app's main window as expected.

The other method that they're talking about from what I understand returns a UITargetedPreview which is based on a UIView instead of a UIViewController, which doesn't really work in this case as I don't want to reimplement another view based on AVPlayerLayer when I have a fully functioning AVPlayerViewController.

Any insight? Am I doing something silly?

Author
Account Strength
100%
Account Age
14 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,715,057
Link Karma
529,042
Comment Karma
607,499
Profile updated: 3 days ago
Posts updated: 5 months ago
Objective-C / Swift

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago