MKMapView 更改视图中的物理位置
我在视图中的某些 xy 坐标 (x:25 y:120) 处放置了一个 MKMapView
,其尺寸约为视图高度的三分之一,并填充了大部分宽度 (w:275,小时:150)。视图中还有其他元素,主要是标签和按钮。
当它出现后查看它时[编辑添加:在模拟器中运行应用程序时](推送到 UINavigationController
堆栈上,表格单元格的详细视图)页面上的所有内容都在其除了 MKMapView
之外的适当位置,它的高度始终位于页面上方。也就是说,在上面显示的测量结果中,它实际上将其置于 x:25 y:-30 处。如果我将其进一步向下移动到页面,例如 y:300,它仍然会向上移动地图的高度,在本例中为 y:150。
为什么它一直在移动?最初将其放置在视图下方 150 像素处以使其最终位于正确的位置,这是一个可怕的黑客行为。
I've put an MKMapView
in a view at certain x-y coordinates (x:25 y:120) at a size that's about a third of the view tall and fills much of the width (w:275, h:150). There are other elements in the view, mostly labels and buttons.
When looking at it after having it appear [edited to add: while running the app in the simulator] (pushed onto a UINavigationController
stack, a detail view of a table cell) everything on the page is in its appropriate place EXCEPT for the MKMapView
, which is always its height further up on the page. That is, in the case of the measurements shown above it actually puts it at x:25 y:-30. If I move it further down the page, say y:300, it still moves it up the height of the map, in this case to y:150.
Why does it keep moving? It's a terrible hack to initially position it 150 pixels farther down the view in order to have it end up at the right place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要设置自动调整大小选项,使顶部、底部、左侧、右侧和高度都是固定的(不可更改)。尽管我不确定,但这可能与它处于滚动视图中有关。
The autosizing options needed to be set such that the top, bottom, left, right, and height were all solid (unchangeable). This may have been related to it being in a scrollview, though I'm not sure.