macos - 如何将信息按钮添加到 OSX(非 iOS)应用程序中的 mapkit 注释

标签 macos swift mapkit mapkitannotation

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

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

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

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

This property is set to nil by default. The right callout view is typically used to link to more detailed information about the annotation. A common view to specify for this property is UIButton object whose type is set to UIButtonTypeDetailDisclosure.

If the view you specify is also a descendant of the UIControl class, you can use the map view’s delegate to receive notifications when your control is tapped. If it does not descend from UIControl, your view is responsible for handling any touch events within its bounds.

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

最佳答案

我得出的答案是:

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

view.rightCalloutAccessoryView = theButton

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

关于macos - 如何将信息按钮添加到 OSX(非 iOS)应用程序中的 mapkit 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32591241/

相关文章:

ios - iPhone sleep 时 Firebase onDisconnect 被触发

iOS Swift MapKit 使注释可由用户拖动?

ios - 多个 Pin 注解

macos - MAC VSCode远程ssh扩展连接Linux服务器失败

c - OSX 10.6 上的 pwrite() 不支持 64 位偏移量

ios - 一个 UIView Swift 中的多个 TableView - 如何同时显示两者

ios - 电子邮件截图而不保存到相机胶卷

swift - 永久释放 MkMapView 的内存

在 OS X 上的 tmp 文件夹中创建临时文件夹

c++ - clang:警告:没有这样的 sysroot 目录:编译 LLVM (3.9.0) 时为 '-mmacosx-version-min=10.5'