Xcode 编辑窗口左边的小圆圈不能点击问题 显示关联控件

1.由于不熟这个工具,导致在国内的各个搜索网站搜了半天的复制粘贴文章,一个搭边的答案的都没有,怒跑国外网站查到答案,现在将这个简单的解决方法贡献出来


2.上面菜单栏-》Editor -》 Show / Hide Code coverage -》如果你不能用的话那么就说显示Hide Code coverage,点一下就可以了


附上截图

不可以用的情况下是这样的:


可以用的情况下是这样的:




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Xcode 中使用 Swift 在地图上显示标记,并在点击标记时显示弹出窗口,可以使用 MapKit 框架中的 MKMapView 和 MKAnnotationView 类。 首先,需要定义一个实现了 MKAnnotation 协议的类来表示地图上的标记: ``` import MapKit class MyAnnotation: NSObject, MKAnnotation { var coordinate: CLLocationCoordinate2D var title: String? var subtitle: String? init(coordinate: CLLocationCoordinate2D, title: String?, subtitle: String?) { self.coordinate = coordinate self.title = title self.subtitle = subtitle } } ``` 然后,在 ViewController 中添加 MKMapView,并设置其 delegate 属性为 self: ``` import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var mapView: MKMapView! override func viewDidLoad() { super.viewDidLoad() mapView.delegate = self // 添加标记 let annotation = MyAnnotation(coordinate: CLLocationCoordinate2D(latitude: 37.33182, longitude: -122.03118), title: "Apple Inc.", subtitle: "Cupertino") mapView.addAnnotation(annotation) } // 实现 MKMapViewDelegate 中的方法 func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { guard let annotation = annotation as? MyAnnotation else { return nil } let identifier = "MyAnnotationView" var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? MKPinAnnotationView if annotationView == nil { annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier) annotationView?.canShowCallout = true annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) } else { annotationView?.annotation = annotation } return annotationView } // 点击详情按钮时触发 func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { if let annotation = view.annotation as? MyAnnotation { let alertController = UIAlertController(title: annotation.title, message: annotation.subtitle, preferredStyle: .alert) alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) present(alertController, animated: true, completion: nil) } } } ``` 在上面的代码中,我们首先在 viewDidLoad 方法中添加了一个 MyAnnotation 标记,并将其添加到 mapView 中。然后,我们实现了 MKMapViewDelegate 中的 viewFor 方法,在其中创建了一个 MKPinAnnotationView,并设置了它的 canShowCallout 属性为 true,表示可以显示弹出窗口,并设置了它的 rightCalloutAccessoryView 属性为一个 UIButton,表示在弹出窗口的右侧添加一个详情按钮。 最后,我们实现了 MKMapViewDelegate 中的 calloutAccessoryControlTapped 方法,当用户点击详情按钮时,会触发这个方法,我们在其中创建了一个 UIAlertController,显示标记的标题和副标题,并在其中添加了一个 OK 按钮来关闭弹出窗口。 这样,当我们运行应用程序时,在地图上就会显示一个名为 "Apple Inc." 的标记,并且当我们点击这个标记时,就会显示一个弹出窗口显示标记的标题和副标题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值