Ber*_*rnd 11 objective-c uitableview ios
我已经在标题区域中实现了MKMapView,即使您将表格向下拖动到反弹区域,我也想将它完全展开到顶部- 与Foursquare类似,请参阅示例:

我当前的默认标头实现(向下拖动时的灰色反弹区域)

在将表格向下拖动时,如何使标题中的地图视图适应顶部的可用标题空间?
我正在使用注释中提到的UIScrollView委托,然后调整地图视图框架的大小,如下所示.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGRect frame = worldmap.frame;
frame.size.height -= scrollView.contentOffset.y;
worldmap.frame = frame;
}
Run Code Online (Sandbox Code Playgroud)
......但是它没有做出正确反应而表现不佳.如何正确设置地图框的新大小?
为表视图实现scrollview委托.由于它是scrollview的子类,因此您可以使用scrollview委托.实现scrollViewDidScroll委托,每当它向下滚动时,更改标题视图的框架并确保该标记始终位于屏幕的中心.
包含UIScrollViewDelegate在.h文件中并实现,
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
//set the frame of MKMapView based on scrollView.contentOffset and make sure the pin is at center of the map view
}
Run Code Online (Sandbox Code Playgroud)
让 headerView 框架很长,然后将地图放在一个区域的中心,以便您可以查看地图底部的有趣区域。
编辑:
我注意到 Foursquare 示例中的图钉位于地图的中心。这意味着您可能应该使用UIScrollViewDelegateusedidScroll方法并在滚动期间动态更改地图的框架。滚动时,您还应该将地图置于图钉区域的中心。
| 归档时间: |
|
| 查看次数: |
7620 次 |
| 最近记录: |