拉下时将UITableView标题视图展开到弹跳区域 [英] Expand UITableView Header View to Bounce Area When Pulling Down

查看:130
本文介绍了拉下时将UITableView标题视图展开到弹跳区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在标题区域中实现了MKMapView,即使将表格向下拖动到反弹区域,我也想将它完全展开到顶部 - 与Foursquare类似,请参阅示例:

I have implemented a MKMapView in the header area and I'd like to expand it fully to the top even when you drag down the table into the bounce area - Similar to Foursquare, see example:

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

My current default header implementation (grey bounce area when dragging down)

如何在标题中使地图视图在拖动时适应顶部的可用标题空间table down?

How do I make the map view in the header adapt to the available header space on top when dragging the table down?

我正在使用评论中提到的UIScrollView委托,然后调整地图视图框架的大小。

I am using the UIScrollView delegate as mentioned in the comments and then resize the map view frame as it follows.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGRect frame = worldmap.frame;
    frame.size.height -= scrollView.contentOffset.y;
    worldmap.frame = frame;  
} 

...但它没有做出正确的反应并且表现不佳。如何正确设置地图框的新大小?

... but it's not quite reacting correctly and performs poorly. How do I set the new size of the map frame correctly?

推荐答案

为表视图实现scrollview委托。由于它是scrollview的子类,因此您可以使用scrollview委托。实现 scrollViewDidScroll 委托,每当它向下滚动时,更改headerview框架并确保该引脚始终位于屏幕中央。

Implement the scrollview delegate for table view. Since it is a subclass of scrollview you can use the scrollview delegates. Implement scrollViewDidScroll delegate and whenever it scrolls down, change the frame of headerview and make sure the pin always comes in the center of the screen.

在.h文件中包含 UIScrollViewDelegate 并实施,

Include UIScrollViewDelegate in .h file and implement,

- (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
}

这篇关于拉下时将UITableView标题视图展开到弹跳区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆