Skip to content

Commit

Permalink
select user location by Press Gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
xxd committed Apr 18, 2012
1 parent 22b6dc6 commit f6db6e4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
8 changes: 3 additions & 5 deletions Dandan/NewItemViewController.h
Expand Up @@ -30,11 +30,9 @@

@property (strong, nonatomic) UIView *imagePane;

@property (strong, nonatomic) MKMapView *mapView; //显示map
@property (strong, nonatomic) CLLocationManager *myLocationManager; //获取long和lat
@property (readonly, nonatomic) CLLocationCoordinate2D coordinate;//以前叫的location
@property (nonatomic, copy, readonly) NSString *title;
@property (nonatomic, copy, readonly) NSString *subtitle;
@property (strong, nonatomic) MKMapView *mapView;
@property (strong, nonatomic) CLLocationManager *myLocationManager;
@property (readonly, nonatomic) CLLocationCoordinate2D coordinate;
@property (strong, nonatomic) UIView *mapPane;
@property (strong, nonatomic) UIView *voicePane;
@property (strong, nonatomic) UIView *songPane;
Expand Down
20 changes: 19 additions & 1 deletion Dandan/NewItemViewController.m
Expand Up @@ -27,7 +27,7 @@ @implementation NewItemViewController
@synthesize imagePane, mapPane, voicePane, songPane, openningPane, panes;
@synthesize scaledImage;
@synthesize items;
@synthesize mapView, myLocationManager, coordinate, currentLocationButton, clearLocationButton, title, subtitle;
@synthesize mapView, myLocationManager, coordinate, currentLocationButton, clearLocationButton;

- (void)initTextView
{
Expand Down Expand Up @@ -258,6 +258,23 @@ - (void)handleLocation{
[self.mapPane addSubview:self.mapView];
[self.mapPane addSubview:clearLocationButton];
[self.mapPane addSubview:currentLocationButton];

UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)];
[self.mapView addGestureRecognizer:longPressGesture];
}
}

-(void)handleLongPressGesture:(UIGestureRecognizer*)sender {
if (sender.state == UIGestureRecognizerStateEnded)
{
[self.mapView removeGestureRecognizer:sender];
}
else
{
CGPoint point = [sender locationInView:self.mapView];
CLLocationCoordinate2D locCoord = [self.mapView convertPoint:point toCoordinateFromView:self.mapView];
ParkPlaceMark *dropPin=[[ParkPlaceMark alloc] initWithCoordinate:locCoord];
[self.mapView addAnnotation:dropPin];
}
}

Expand Down Expand Up @@ -293,6 +310,7 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *
[myLocationManager stopUpdatingLocation];
}


- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{
mPlacemark = placemark;
[mapView addAnnotation:placemark];
Expand Down
4 changes: 2 additions & 2 deletions Dandan/ParkPlaceMark.m
Expand Up @@ -4,10 +4,10 @@ @implementation ParkPlaceMark
@synthesize coordinate;

- (NSString *)subtitle{
return @"Put some text here";
return @"可以增加用来回忆的详细位置信息";
}
- (NSString *)title{
return @"Parked Location";
return @"您所选择的单单item位置";
}

-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
Expand Down

0 comments on commit f6db6e4

Please sign in to comment.