Creating a custom UI view class to use as a map annotation

纵然是瞬间 提交于 2019-12-31 05:12:10

问题


I created a custom UIView using storyboard. I don't want this at the coordinates that it is in in my storyboard, but I want to be able to reuse it throughout my app at different locations on a map like this. I also want to be able to update the text in there at the users request, and the number in there should increase whenever the green button is clicked. I also want to customize the image below it, like I learned in this question so that the user annotation has an image and this callout above it. The callout would only be there if the user has posted some text. It would look like this.

My previously linked example uses a method called setcenter to place the coordinate in the middle of the annotation, but it looks like the MGLMapView documentation and uiview documentation contain at most a setcentercoordinate function, so this is why I tried creating the annotation in storyboard instead of coding it in swift, because I didn't know how to add things to the annotation. It also doesn't look like that example show's how to constrain views to the bottom corners, like I did with my buttons (There is one view for the rocket and person button, and one view for the arrow button and the number).

Because I want to update the text field and that number(which is a label), I don't know if storyboard is the best idea to create this. I also don't know if I can use a storyboard object at a dynamic location, and create multiple of them throughout the map

来源:https://stackoverflow.com/questions/53689040/creating-a-custom-ui-view-class-to-use-as-a-map-annotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!