【发布时间】:2017-03-26 20:28:36
【问题描述】:
我知道如何做摇动手势和如何分别找到位置,但是我不知道用户摇动设备后如何找到位置。我有 xcode 6.4 版。
现在我有一个动作结束功能。还有一个 showUserLocation 函数。
我想在 motionEnded 中添加一个调用 showUserLocation 的语句,以便在用户摇动手机时找到该位置。
override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent) {
?????
}
// Showing the user location
func showUserLocation(sender : AnyObject) {
let status = CLLocationManager.authorizationStatus()
//Asking for authorization to display current location
if status == CLAuthorizationStatus.NotDetermined {
locationManager.requestWhenInUseAuthorization()
} else {
locationManager.startUpdatingLocation()
}
【问题讨论】:
-
这个问题太宽泛了,答案很简单,虽然可能很难实现,因为在软件开发中几乎总是如此,在手机震动之后,在你的代码中,你知道震动已经发生了,现在找到位置
-
更具体地说:这些括号中的内容会覆盖 func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent) { ????连接到我设置的 showUserLocation 函数
-
你不能问这样的问题,在 cmets 中发布代码太难,任何人都无法理解并给你答案,括号中是你想要的任何代码,以某种形式或语法,你可以如果在范围内,在正确的线程上可访问,则调用您的函数
-
Brian,感谢您抽出宝贵时间帮助我解决此问题。我正在寻找更具体的答案。我现在将编辑我的问题,希望能更清楚。