我正在尝试为 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/