0
我在斯威夫特新的,我堆放着每次回到我的时候这段代码和“对用户使用未解决的标识符‘showAlert’的输入区域和用户出口区域:使用未解决的标识符“showAlert”斯威夫特
func setupData() {
// 1. check if system can monitor regions
if CLLocationManager.isMonitoringAvailable(for: CLCircularRegion.self) {
// 2. region data
let title = "Primo punto"
let coordinate = CLLocationCoordinate2DMake(38.121973, 13.360855)
let regionRadius = 300.0
// 3. setup region
let region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: coordinate.latitude,
longitude: coordinate.longitude), radius: regionRadius, identifier: title)
locationManager.startMonitoring(for: region)
// 4. setup annotation
let restaurantAnnotation = MKPointAnnotation()
restaurantAnnotation.coordinate = coordinate;
restaurantAnnotation.title = "\(title)";
mapView.addAnnotation(restaurantAnnotation)
// 5. setup circle
let circle = MKCircle(center: coordinate, radius: regionRadius)
mapView.add(circle)
}
else {
print("System can't track regions")
}
}
// 6. draw circle
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
let circleRenderer = MKCircleRenderer(overlay: overlay)
circleRenderer.strokeColor = UIColor.red
circleRenderer.lineWidth = 1.0
return circleRenderer
}
// 1. user enter region
func locationManager(manager: CLLocationManager, didEnterRegion region: CLRegion) {
showAlert("enter \(region.identifier)")
}
// 2. user exit region
@nonobjc func locationManager(manager: CLLocationManager, didExitRegion region: CLRegion) {
showAlert("exit \(region.identifier)")
}
}
是什么showAlert()?你有没有在你的项目中使用这个名字创建任何方法? – PGDev
我有这样的功能:\t FUNC showAlert(标题:字符串){ \t \t设警报= UIAlertController(标题:标题,消息:无,preferredStyle:.alert) \t \t alert.addAction(UIAlertAction(标题: “取消” ,风格:.DEFAULT,处理程序:{(动作)在 \t \t \t alert.dismiss(动画:真,完成:无) \t \t})) \t \t self.present(警报,动画:真,完成:无) \t} 而现在看来工作但他们回到我身边:线程6:SIGABRT信号 –