GISMapView를 UIScrollView에 추가하고 해당 UIScrollView에 Table View를 추가했습니다. 지도에서 임의의 위치를 길게 누르면 해당 주소를 가져 와서 해당 주소를 표보기에 추가하고 그 위치에 표식을 추가하고 싶습니다.iOS의 Google지도에 제스처 인식기를 길게 추가
길게 누르는 제스처 인식기를지도에 추가하기위한 아래 코드를 작성했지만 작동하지 않습니다.
- (void)viewDidLoad
{
[super viewDidLoad];
self->map.delegate = self;
CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];
UIScrollView *scroll=[[UIScrollView alloc] initWithFrame:fullScreenRect];
[self.view addSubview:scroll];
scroll.contentSize=CGSizeMake(320,1000);
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:21.0000 longitude:78.0000 zoom:4.5];
map = [GMSMapView mapWithFrame:CGRectMake(0,0, self.view.frame.size.width,390) camera:camera];
[scroll addSubview:map];
UITableView *tab = [[UITableView alloc]initWithFrame:CGRectMake(0, 410, self.view.bounds.size.width, 300) style:UITableViewStylePlain];
[scroll addSubview:tab];
tab.delegate = self;
tab.dataSource = self;
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(mapLongPress:)];
longPressGesture.minimumPressDuration = 1.5;
[map addGestureRecognizer:longPressGesture];
}
-(void)mapLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{
if(gestureRecognizer.state == UIGestureRecognizerStateBegan)
{
NSLog(@"%f",coordinate.latitude);
NSLog(@"%f",coordinate.longitude);
}
}
여기서 주요 문제는 MapView를 길게 누르면 "mapLongPress"메서드가 호출되지 않는다는 것입니다.
아무도 도와주세요.
를 사용할 수 있습니다. 이거 한번 해봐. http://stackoverflow.com/questions/1685956/uiscrollview-touchesbegan/17759373#17759373 – Rajneesh071