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?
Subreddit
Post Details
- Posted
- 5 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/iOSProgramm...