gpt4 book ai didi

ios - 将按钮连接到引脚标注

转载 作者:行者123 更新时间:2023-11-28 06:09:23 24 4
gpt4 key购买 nike

我试图在开车时获取我要搜索的位置,但它给了我这个

Error Message : Thread 1: signal SIGABRT

有人可以帮忙吗?我正在使用 Xcode9 和 Swift4

//Getting direction of location
func getDirections(){
if let selectedPin = selectedPin {
let mapItem = MKMapItem(placemark: selectedPin)
let launchOptions = [MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving]
mapItem.openInMaps(launchOptions: launchOptions)
}
}
extension ViewController : MKMapViewDelegate {
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?{
if annotation is MKUserLocation {
//return nil so map view draws "blue dot" for standard user location
return nil
}
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId) as? MKPinAnnotationView
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView?.pinTintColor = UIColor.orange
pinView?.canShowCallout = true
let smallSquare = CGSize(width: 30, height: 30)
let button = UIButton(frame: CGRect(origin: CGPoint.zero, size: smallSquare))
button.setBackgroundImage(UIImage(named: "Car"), for: .normal)
button.addTarget(self, action: Selector(("getDirections")), for: .touchUpInside)
pinView?.leftCalloutAccessoryView = button
return pinView
}
}
  • thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT frame #0: 0x00000001150b9d42 libsystem_kernel.dylib__pthread_kill + 10
    frame #1: 0x00000001150f1457 libsystem_pthread.dylib
    pthread_kill + 90 frame #2: 0x0000000114d790e7 libsystem_c.dylibabort + 127
    frame #3: 0x0000000114b0b91f libc++abi.dylib
    abort_message + 245 frame #4: 0x0000000114b0babb libc++abi.dylibdefault_terminate_handler() + 265
    frame #5: 0x000000010f9571be libobjc.A.dylib
    _objc_terminate() + 97 frame #6: 0x0000000114b27159 libc++abi.dylibstd::__terminate(void (*)()) + 8
    frame #7: 0x0000000114b26e0a libc++abi.dylib
    __cxa_rethrow + 99 frame #8: 0x000000010f9570dc libobjc.A.dylibobjc_exception_rethrow + 40
    frame #9: 0x0000000113b00a39 CoreFoundation
    CFRunLoopRunSpecific + 537 frame #10: 0x00000001155f29c6 GraphicsServicesGSEventRunModal + 62
    frame #11: 0x00000001107295e8 UIKit
    UIApplicationMain + 159
    • frame #12: 0x000000010f038067 Mapmain at AppDelegate.swift:12
      frame #13: 0x0000000114ca6d81 libdyld.dylib
      start + 1 frame #14: 0x0000000114ca6d81 libdyld.dylib`start + 1 (lldb)

最佳答案

我认为你需要做两个改变

第一次使用

#selector(getDirections)

代替

Selector(("getDirections"))

第二个用于 Swift 4 使用

@objc func getDirections()

代替

func getDirections()

关于ios - 将按钮连接到引脚标注,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47170556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com