Long version: I am writing an application for iOS 8in Swift, and its main functionality requires that slideshows display varieties of images and videos . Given that, according to my information, AVPlayerit cannot display images (I tried loading the image URL in the same way as I fed the video URL, and with no luck), this requires me to add and remove UIImageViewor AVPlayerfrom the view to display relevant content. However, in order to display the content correctly, I need to hide the application navigationbarby default. The idea is to show it again if the user clicks on the view. A view has TapGestureRecognizerthat serves this purpose. These touch gestures work correctly, assuming the content of the view isimageview. However, if the view currently contains AVPlayer, gestures are not accepted, which allows me not to show the user navigationbarand leave the view. Here's how to AVPlayeradd to the view:
if (Utilities.IsVideo(url)) {
var escapedUrl = url.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
let player = AVPlayer(URL: NSURL(string: escapedUrl!))
var cont = AVPlayerViewController()
cont.player = player
self.addChildViewController(cont)
self.view.addSubview(cont.view)
cont.view.frame = self.view.frame
player.play()
}
Short version: I have a view in an iOS application containing TapGestureRecognizer. Cranes do not pass through AVPlayer, which is added to the view. How to detect these taps?
It is worth mentioning that if the user clicks on one of the multimedia controls (for example, the play button), the touch gesture touches and its action starts.
source
share