在SKMaps for iOS上,我正在尝试添加一个按钮来实现“找我”功能。该按钮在地图上正确呈现,但是当我点击它时,它会在名为IBGMethodSwizzler
如果这是与SKMaps相关的任何想法吗?
在我初始化地图时,我使用此代码
let findMeButton = UIButton(frame: CGRectMake(53, 90, 44, 44))
findMeButton.setBackgroundImage(UIImage(named: "find_me"), forState: .Normal)
findMeButton.addTarget(self, action: Selector("findMe:"), forControlEvents: UIControlEvents.TouchUpInside)
self.mapView.addSubview(findMeButton)
这是findMe选择器
func findMe(sender:UIButton) {
println("this is never called")
}
将UIButton添加为mapView的子视图是否存在已知限制?
谢谢:)
答案 0 :(得分:0)
请尝试以下代码段:
var positionMeButton: UIButton = UIButton.buttonWithType(UIButtonType.System) as! UIButton
positionMeButton.frame = CGRectMake(10.0, CGRectGetHeight(self.view.frame) - 60.0, 100.0, 40.0)
positionMeButton.setTitle("Position me", forState: UIControlState.Normal)
positionMeButton.addTarget(self, action:"positionMe", forControlEvents: UIControlEvents.TouchUpInside)
positionMeButton.backgroundColor = UIColor.lightGrayColor()
positionMeButton.autoresizingMask = UIViewAutoresizing.FlexibleTopMargin
positionMeButton.titleLabel?.adjustsFontSizeToFitWidth = true
self.mapView.addSubview(positionMeButton);
internal func positionMe() {
}