Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 从MapView中选择位置_Iphone_Objective C_Xcode_Mapkit_Cllocation - Fatal编程技术网

Iphone 从MapView中选择位置

Iphone 从MapView中选择位置,iphone,objective-c,xcode,mapkit,cllocation,Iphone,Objective C,Xcode,Mapkit,Cllocation,我在考虑一个应用程序,用户可以在iphone应用程序上选择一个位置。我在谷歌上搜索了一下,没有发现任何有用的东西 我的问题是,是否可以让用户使用MapKit/CLLocation从iphone应用程序中选择位置?如果是,请帮助我从哪里开始 谢谢看一看。答案不仅告诉您如何获取坐标,还告诉您如何在地图上放置pin(注释)。您可以在地图上添加长按手势识别器: UILongPressGestureRecognizer* lpgr = [[UILongPressGestureRecognizer allo

我在考虑一个应用程序,用户可以在iphone应用程序上选择一个位置。我在谷歌上搜索了一下,没有发现任何有用的东西

我的问题是,是否可以让用户使用MapKit/CLLocation从iphone应用程序中选择位置?如果是,请帮助我从哪里开始


谢谢

看一看。答案不仅告诉您如何获取坐标,还告诉您如何在地图上放置pin(注释)。

您可以在地图上添加长按手势识别器:

UILongPressGestureRecognizer* lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 1.5;
lpgr.delegate = self;
[self.map addGestureRecognizer:lpgr];
[lpgr release];
在handle long press方法中,获取CLLocationCordinate2D:

- (void) handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
    /*
     Only handle state as the touches began
     set the location of the annotation
     */

    CLLocationCoordinate2D coordinate = [self.map convertPoint:[gestureRecognizer locationInView:self.map] toCoordinateFromView:self.map];

    [self.map setCenterCoordinate:coordinate animated:YES];

  // Do anything else with the coordinate as you see fit in your application

   }
}