Iphone 将UIButton固定到地图视图

Iphone 将UIButton固定到地图视图,iphone,uibutton,mkmapview,cgrect,Iphone,Uibutton,Mkmapview,Cgrect,我在注释视图上创建一个UIButton,如下所示: UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; CGPoint point = [mainMapView convertCoordinate:sac.coordinate toPointToView:self.smallView]; button.frame = CGRectMake(point.x - 30, point.y - 30, 60, 60)

我在注释视图上创建一个UIButton,如下所示:

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
CGPoint point = [mainMapView convertCoordinate:sac.coordinate toPointToView:self.smallView];
button.frame = CGRectMake(point.x - 30, point.y - 30, 60, 60);

它工作得很好,但是当我移动地图时,按钮不会随着地图一起移动。有没有一种方法可以用
CGRectMake
来绘制按钮,它将
按钮.frame
放在地图上而不是视图上?

你真的应该使用MKMapAnnotation来实现这一点。引导您完成设置所需代理的基础知识。 基本上,将按钮保持在某个位置的所有工作都已为您完成--您只需利用它。
显示如何为覆盖视图和各种其他内容设置图像。

我确实使用注释,但除了注释之外,我还需要按钮。sac.coordinate是注释的坐标属性。因此,将按钮放在注释视图中,这就是Josh所说的。我需要一个带有自定义图像的注释,按下该图像时,会创建一个大于注释的按钮,并显示一个新图像。我都能做到。我所需要的就是让这个按钮和地图一起移动。所以我想你需要做的是让你的第一个按钮导致另一个注释被添加到地图上。注释被锚定到地图上,因此如果需要锚定的内容,则需要使用注释。希望有帮助。