iOS - 无法获取标注中按钮的 DetailDisclosure

标签 ios swift uibutton calloutview

我在 iOS 9 中使用 Swift。无论我选择什么按钮类型,除了 ContactAdd 之外,都只会呈现信息图标。我正在尝试为 map View 中标注的右侧获取 DetailDisclosure 图标。这是代码:

    let rightButton = UIButton(type: UIButtonType.DetailDisclosure);
    rightButton.addTarget(self, action: "buttonTapped:", forControlEvents: UIControlEvents.TouchUpInside)
    annotationView.rightCalloutAccessoryView = rightButton;

最佳答案

您已经创建了图钉吗?尝试将按钮 .DetailDisclosure 添加到 pinView

var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? 
pinView!.rightCalloutAccessoryView = UIButton.buttonWithType(.DetailDisclosure) as UIButton

更新 这对我有用

let identifier = "pin"
var view: MKPinAnnotationView
view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view.canShowCallout = true
view.calloutOffset = CGPoint(x: -5, y: 5)
view.rightCalloutAccessoryView = UIButton(type: .DetailDisclosure) as UIView

关于iOS - 无法获取标注中按钮的 DetailDisclosure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33989532/

相关文章:

c# - 在 MonoTouch/iOS 设备 (iPhone/iPad) 上使用 protobuf-net 进行 JIT 编译错误

ios - 在 XCTestCase 期间切换互联网可用性

ios - 多个绘图空间或移动的轴/图

ios - 从 podspec 或 info.plist 中检索 pod 版本到代码中

swift - 确定 UIImageView 中图像的框架

ios - 如何在两点之间连续弹跳uibutton

ios - UIButton 不改变图像?

ios - 每五秒发出一次声音循环警报

ios - 向我的 UIButton 添加一个封闭的圆圈

ios - 在 iOS 框架中嵌入 .dylib