Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios XCode-在MKAnnotationView中将按钮设置为leftCalloutAccessoryView_Ios_Swift_Mapkit_Mapkitannotation - Fatal编程技术网

Ios XCode-在MKAnnotationView中将按钮设置为leftCalloutAccessoryView

Ios XCode-在MKAnnotationView中将按钮设置为leftCalloutAccessoryView,ios,swift,mapkit,mapkitannotation,Ios,Swift,Mapkit,Mapkitannotation,我正在尝试将文本为“button”的按钮设置为左侧详图索引附件视图。这是我到目前为止所拥有的 func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { if let annotation = annotation as? LocationObjects{ if let view = mapView.dequeueReusableAnnotat

我正在尝试将文本为“button”的按钮设置为左侧详图索引附件视图。这是我到目前为止所拥有的

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    if let annotation = annotation as? LocationObjects{
        if let view = mapView.dequeueReusableAnnotationView(withIdentifier: annotation.identifier){
            return view
        }else{
            let view = MKAnnotationView(annotation: annotation, reuseIdentifier: annotation.identifier)
            view.isEnabled = true
            view.canShowCallout = true
            view.image = annotationPin

            let test = UIButton(type: .system)
            test.setTitle("Button", for: .normal)

            view.leftCalloutAccessoryView = test
            return view
        }
    }
    return nil
}
之后会抛出一个错误

test.setTitle("Button", for: .normal)
但如果我删除该行并设置

let test = UIButton(type: .system)

如何将按钮设置为文本而不是图像或默认系统图标

谢谢

let test = UIButton(type: .detailDisclosure)