我试图弹出一个popover为我的应用程序。到目前为止,弹出窗口弹出一个固定的坐标,我试图让它弹出到用户点击的位置。这是我的:touchesBegan函数永远不会被输入
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("touchesbegan")
for touch in touches{
//Handle touch
let location = touch.locationInView(self.view)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("ColonyPopoverController") as! ColonyPopoverController
vc.modalPresentationStyle = .Popover
vc.preferredContentSize = CGSizeMake(200, 150)
if let popoverController = vc.popoverPresentationController {
popoverController.delegate = self
popoverController.sourceRect = CGRectMake(location.x, location.y, 20, 10)
popoverController.sourceView = self.view
self.presentViewController(vc, animated: true, completion: nil)
}
}
}
我注意到,打印语句从不打印,当我点击模拟器。
我在我看来有interaction
和multi-touch
启用。我知道这工作得很好,因为我也有它与谷歌地图整合,所以,当我点击,会出现一个谷歌的针:
func mapView(mapView: GMSMapView!, didTapAtCoordinate coordinate: CLLocationCoordinate2D) {
print("You tapped at \(coordinate.latitude), \(coordinate.longitude)")
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(coordinate.latitude, coordinate.longitude)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView
}
,我看到了打印报表打印为好。不知道我在这里错过了什么。
用户交互是为上海华和视图均启用
谢谢您的回答。超级视图和视图都启用了用户交互,附加了屏幕截图和更新后的问题。 – Siddhartha
我找到了原因。 Googlemaps的GMSView在视图中使用其他手势,并且必须禁止:'''mapView.settings.consumesGesturesInView = false;'''。 – Siddhartha