久久久久久久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 創建圖像)
主站蜘蛛池模板: 美女张开腿露出尿口 | 91网站视频在线观看 | 精品国产综合 | 操到爽 | 国产欧美一区二区三区在线看 | 久久精品国产久精国产 | 国产有码 | 精品国产视频在线观看 | 国户精品久久久久久久久久久不卡 | 日日夜夜精品视频 | 欧美精品一区二区三区在线播放 | 日本久久精 | 在线播放中文 | 亚洲在线免费 | 精品国产青草久久久久96 | 国产精品成人品 | 日韩第一区 | 精品三级在线观看 | 午夜精品| 国产xxxx岁13xxxxhd | 国产精品黄视频 | 中文字幕视频在线看5 | 黄色片免费看视频 | 一级黄色淫片 | 亚洲一级视频在线 | 亚洲二区在线 | 欧美一级视频免费看 | 91av久久久 | 99福利| 国产欧美精品一区 | 欧美黄色免费网站 | 免费特黄视频 | 日韩快播电影 | 欧美在线a | 男女网站免费观看 | 超碰在线播| 岛国av免费在线观看 | 国产成人精品av | 一级做a爰片久久毛片 | 国产成人精品一区二区三区视频 | 黄色大片在线视频 |