久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

新四方場地細節圖

New foursquare venue detail map(新四方場地細節圖)
本文介紹了新四方場地細節圖的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我真的很喜歡foursquare 設計場地細節視圖的方式.特別是在視圖的標題"中帶有場地位置的地圖......它是如何完成的?細節顯然是一些uiscrollview(也許是uitableview?),在它后面(在標題中)有一張地圖,所以當你向上滾動時,地圖會隨著滾動視圖的反彈而被發現......有沒有人知道如何做到這一點?

I really love the way foursquare designed venue detail view. Especially the map with venue location in the "header" of view ... How was it done? Details are obviously some uiscrollview (maybe uitableview?) and behind it (in the header) there is a map so when you scroll up the map is beeing uncovered as the scroll view bounces... does anyone has an idea how to do this?

推薦答案

這是我設法重現它的方式:-

Here's the way I manage to reproduce it:-

您需要一個帶有 UIScrollView 作為其視圖的 UIViewController.然后,您添加到滾動視圖的 UIView 的內容應如下所示:-

You need a UIViewController with a UIScrollView as its view. Then, the content of the UIView you add to your scrollview should look like this :-

- MKMapView 的框架有一個負的y 位置.在這種情況下,我們只能看到默認狀態下(拖動前)的 100pts 地圖.
- 您需要在 MKMapView 實例上禁用縮放和滾動.

- The frame of the MKMapView have a negative y position. In this case, we can only see 100pts of the maps in the default state (before dragging).
- You need to disable zooming and scrolling on your MKMapView instance.

那么,訣竅就是向下拖動MKMapViewcenterCoordinate,并調整其中心位置.

Then, the trick is to move down the centerCoordinate of the MKMapView when you drag down, and adjust its center position.

為此,我們計算 1point 表示多少緯度,以便我們知道在屏幕上拖動 x 個點時地圖的中心坐標應該移動多少:-

For that, we compute how much 1point represent as a delta latitude so that we know how much the center coordinate of the map should be moved when being dragged of x points on the screen :-

- (void)viewDidLoad {
    [super viewDidLoad];
    UIScrollView* scrollView = (UIScrollView*)self.view;
    [scrollView addSubview:contentView];
    scrollView.contentSize = contentView.frame.size;
    scrollView.delegate = self;
    center = CLLocationCoordinate2DMake(43.6010, 7.0774);
    mapView.region = MKCoordinateRegionMakeWithDistance(center, 1000, 1000);
    mapView.centerCoordinate = center;
    //We compute how much latitude represent 1point.
    //so that we know how much the center coordinate of the map should be moved 
    //when being dragged.
    CLLocationCoordinate2D referencePosition = [mapView convertPoint:CGPointMake(0, 0) toCoordinateFromView:mapView];
    CLLocationCoordinate2D referencePosition2 = [mapView convertPoint:CGPointMake(0, 100) toCoordinateFromView:mapView];
    deltaLatFor1px = (referencePosition2.latitude - referencePosition.latitude)/100;
}

一旦這些屬性被初始化,我們需要實現 UIScrollViewDelegate 的行為.當我們拖動時,我們將以點表示的移動轉換為緯度.然后,我們使用該值的一半移動地圖的中心.

Once those properties are initialized, we need to implement the behavior of the UIScrollViewDelegate. When we drag, we convert the move expressed in points to a latitude. And then, we move the center of the map using the half of this value.

- (void)scrollViewDidScroll:(UIScrollView *)theScrollView {
    CGFloat y = theScrollView.contentOffset.y;
    // did we drag ?
    if (y<0) {
        //we moved y pixels down, how much latitude is that ?
        double deltaLat = y*deltaLatFor1px;
        //Move the center coordinate accordingly 
        CLLocationCoordinate2D newCenter = CLLocationCoordinate2DMake(center.latitude-deltaLat/2, center.longitude);
        mapView.centerCoordinate = newCenter;
    }
}

您會得到與foursquare 應用程序相同的行為(但更好:在foursquare 應用程序中,地圖居中器往往會跳躍,在這里,更改中心很順利).

You get the same behavior as the foursquare app (but better: in the foursquare app, the maps recenter tends to jump, here, changing the center is done smoothly).

這篇關于新四方場地細節圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

iOS - Using storyboard and autolayout to center the UIScrollView(iOS - 使用故事板和自動布局使 UIScrollView 居中)
get index or tag value from imageview tap gesture(從 imageview 點擊手勢獲取索引或標簽值)
UIScrollView not scrolling regardless of large contentSize(無論內容大小如何,UIScrollView 都不會滾動)
Clean autorotation transitions in a paging UIScrollView(清除分頁 UIScrollView 中的自動旋轉轉換)
UIScrollView zooming with Auto Layout(UIScrollView 使用自動布局縮放)
How to create an image from a UIView / UIScrollView(如何從 UIView/UIScrollView 創建圖像)
主站蜘蛛池模板: 国产美女一区二区三区 | 欧美在线视频一区二区 | 日韩欧美精品一区二区 | 亚洲精品视频一区 | 操操操日日日 | 特级毛片爽www免费版 | 成年人毛片| 黄色亚洲 | 亚洲在线视频 | 国产蜜臀av | 国产超级av | 热久久中文字幕 | 欧美一级视频 | 日本国产视频 | 久热99| 免费视频成人 | 日韩一级片 | 国产美女一区 | 成人在线a | 又黄又爽的免费视频 | 国产成人97精品免费看片 | 国产成人三级一区二区在线观看一 | 欧洲精品一区二区 | 精品国产一区二区三区四区 | 欧美伊人网 | 国产精品一品二区三区的使用体验 | 日韩av在线看 | 国产香蕉视频 | 国产精品福利视频 | 成人午夜又粗又硬又大 | 一级片观看 | 国产一级二级片 | h片免费观看| 国产丝袜视频 | 亚洲午夜一区 | 性生活视频网站 | 日本激情视频 | 成人91看片| 黄色网址免费看 | 亚洲在线视频 | 成人午夜激情 |