我试图使用类型为.pagesheet的模式样式将视图控制器呈现为popoverviewcontroller。在这里,我试图添加一个轻敲手势识别器来点击这个popoverviewcontroller点击其视图。但它没有在iOS 9中检测到点击。以下是手势识别器的代码
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let recog : UITapGestureRecognizer = UITapGestureRecognizer.init(target: self, action:#selector(HandleTap))
recog.numberOfTapsRequired = 1
recog.numberOfTouchesRequired = 1
recog.cancelsTouchesInView = false
recog.delegate = self
self.view.window?.addGestureRecognizer(recog)
}
func HandleTap(sender:UITapGestureRecognizer) -> Void
{
if(sender.state == UIGestureRecognizerState.Ended)
{
var location : CGPoint = sender.locationInView(self.presentingViewController?.view)
//var location : CGPoint = sender.locationInView(self.view?.window)
if(!(self.view.pointInside(self.view.convertPoint(location, toView: self.view?.window), withEvent: nil)))
{
self.view.window?.removeGestureRecognizer(sender)
self.dismissViewControllerAnimated(true, completion: nil)
}
}
}
答案 0 :(得分:1)
将 long expiration = 0L;
if (!producer.getDisableMessageTimestamp()) {
long timeStamp = System.currentTimeMillis();
message.setJMSTimestamp(timeStamp);
if (timeToLive > 0) {
expiration = timeToLive + timeStamp;
}
}
message.setJMSExpiration(expiration);
//me: timeToLive coming from default values of Producer/JmsTemplate...
设置为您处理点按的userinteractionenable
上的true
。第二件事你为什么在view
做你的东西?您应该使用viewDidAppear
添加手势识别器。
更新:
viewDidLoad
如果您使用导航控制器,那么</ p>
self.view.window?.userInteractionEnabled = true
希望这会有所帮助:)