Ios 无法从QLPreviewController.view接收任何触摸事件
为了自定义预览文件控制器,我创建了一个Ios 无法从QLPreviewController.view接收任何触摸事件,ios,swift,Ios,Swift,为了自定义预览文件控制器,我创建了一个DocumentPreviewController:UIController,然后创建DocumentPreviewController.view.addSubView(QLPreviewController.view)。如果我全屏显示QLPreviewController.view,即使我为QLPreviewController.view添加了uigesturecognizer,我也无法接收任何touch事件。有人能帮我吗 import UIKit imp
DocumentPreviewController:UIController
,然后创建DocumentPreviewController.view.addSubView(QLPreviewController.view)
。如果我全屏显示QLPreviewController.view
,即使我为QLPreviewController.view添加了uigesturecognizer
,我也无法接收任何touch事件
。有人能帮我吗
import UIKit
import QuickLook
class CustomiseDocumentPreviewController: UIViewController, UIGestureRecognizerDelegate
{
var url : String!
override func viewDidLoad()
{
let previewController = CustomisePreviewController()
previewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, 300)
previewController.filePath = url
let singleGuesture = UITapGestureRecognizer()
singleGuesture.addTarget(self, action: #selector(GlipDocumentPreviewController._singleTap))
singleGuesture.numberOfTapsRequired = 1
singleGuesture.delegate = self
previewController.view.userInteractionEnabled = true
previewController.view.addGestureRecognizer(singleGuesture)
previewController.view.multipleTouchEnabled = true
self.view.backgroundColor = UIColor.redColor()
self.view.addSubview(previewController.view)
}
func _singleTap()
{
if self.navigationController!.navigationBarHidden
{
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
else
{
self.navigationController?.setNavigationBarHidden(true, animated: true)
}
// self.navigationController?.navigationBarHidden = !(self.navigationController!.navigationBarHidden)
print("====")
}
public func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool
{
return true
}
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool
{
return true
}
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOfGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool
{
return true
}
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailByGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool
{
return true
}
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool
{
return true
}
===========
import QuickLook
class CustomisePreviewController: QLPreviewController, QLPreviewControllerDataSource, QLPreviewControllerDelegate
{
var filePath : String?
override func viewDidLoad()
{
self.dataSource = self
self.listSubViewOfView(self.view)`
}
func numberOfPreviewItemsInPreviewController(controller: QLPreviewController) -> Int {
return 1
}
func previewController(controller: QLPreviewController, previewItemAtIndex index: Int) -> QLPreviewItem {
return NSURL(fileURLWithPath: filePath!)
}
func previewController(controller: QLPreviewController, shouldOpenURL url: NSURL, forPreviewItem item: QLPreviewItem) -> Bool {
return true
}
func previewControllerDidDismiss(controller: QLPreviewController)
{
}
func previewControllerWillDismiss(controller: QLPreviewController)
{
}
我向CustomiseDocumentPreviewController.view
和CustomisePreviewController.view
添加了单触事件,正如您可以从我的代码中看到的那样,CustomisePreviewController.view
在屏幕的上半部分,如果我触摸该空间,则不会发生任何事情。但是,如果我触摸下面的屏幕,它就会工作。
我已经搜索了几天,似乎无法从qlviewcontroller
获取触摸事件?。
1.如果您有任何方法可以侦听“QLViewController.view”触摸事件,请帮助我。
2.如果不能,如果您需要定制预览文件控制器,您将如何做。我们需要更多代码来帮助您。编辑您的问题并粘贴相关代码。如果您认为对我们有用,还可以添加视图或情节提要的屏幕截图。什么是“QLViewController”?在我看来,它类似于UITableView或UICollectionView或其他相关内容。这可能是你没有收到触摸事件的原因。也许可以尝试谷歌搜索:“swift uicollectionview手势识别器”。我们需要更多代码来帮助您。编辑您的问题并粘贴相关代码。如果您认为对我们有用,还可以添加视图或情节提要的屏幕截图。什么是“QLViewController”?在我看来,它类似于UITableView或UICollectionView或其他相关内容。这可能是你没有收到触摸事件的原因。也许可以试试谷歌搜索:“swift uicollectionview手势识别器”。