【问题标题】:How do I add the Info Button to a mapkit annotation in OSX (not ios) application如何将信息按钮添加到 OSX(不是 ios)应用程序中的 mapkit 注释
【发布时间】:2015-12-12 00:22:17
【问题描述】:

我正在尝试为 OS X 应用程序创建 mapkit 注释,并且默认行为不显示信息按钮。在 iOS 应用程序中,我会使用以下内容:

view.rightCalloutAccessoryView = UIButton.buttonWithType(.DetailDisclosure) as! UIView

在 OS X 应用程序中,没有 UIButton - 我不认为答案是加载 UIKit 框架,但是是吗?还有其他方法吗? NSButton 没有 Info 或 DetailDisclosure 类型。

更多研究:Apple 的 Mac 开发人员库声明 MKAnnotationView,rightCalloutAccessoryView 属性:

此属性默认设置为 nil。右侧标注视图通常用于链接到有关注释的更详细信息。为该属性指定的常见视图是 UIButton 对象,其类型设置为 UIButtonTypeDetailDisclosure。

如果您指定的视图也是 UIControl 类的后代,您可以使用地图视图的委托在您的控件被点击时接收通知。如果它不是从 UIControl 派生的,则您的视图负责处理其范围内的任何触摸事件。

我似乎需要 UIKit,但它在 Mac 应用程序中不可用 - 除非这是我犯的新手错误。感谢您的帮助 - 我已经为此绊倒了几天,但一无所获。

【问题讨论】:

    标签: macos swift mapkit mapkitannotation


    【解决方案1】:

    我想出的答案是:

    var theButton: NSButton = NSButton()
    theButton.setButtonType(NSButtonType.MomentaryPushInButton)
    
    view.rightCalloutAccessoryView = theButton
    

    它没有给我我正在寻找的信息按钮,但有了这个按钮,我应该能够自定义它以生成类似的东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 2014-09-10
      相关资源
      最近更新 更多