久久久久久久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 創建圖像)
主站蜘蛛池模板: 亚洲高清在线免费观看 | 男女又爽又黄视频 | 国产日韩欧美一区二区 | 午夜影院操 | 少妇精品久久久久久久久久 | 国产欧美日韩综合精品一区二区 | 日韩成人免费av | 久色视频在线观看 | 日本激情一区二区 | 福利视频日韩 | a天堂在线| 一区二区三区四区在线视频 | 日本二区 | 久久精品日产第一区二区三区 | 天天躁天天操 | 男人天堂网址 | 精品日韩一区二区三区 | 国产午夜在线 | 91视频国产一区 | 午夜影视在线观看 | 国产高清在线观看 | 99久久久无码国产精品 | 国内精品久久久久久久 | 精品一区二区三区免费视频 | 一级午夜aaa免费看三区 | 久久黄网| 欧美视频在线一区 | 一级毛片在线播放 | 久久久久久久久久久久91 | 国产我和子的乱视频网站 | 国产www成人 | 99久久99| 精品乱码一区二区三四区 | 乱码av午夜噜噜噜噜动漫 | 日韩在线精品视频 | 国产成人久久精品一区二区三区 | 国产一区二区精品在线观看 | 91麻豆精品国产91久久久久久 | 综合久久亚洲 | 天天色图 | 亚洲成av人片在线观看 |