Generalnie mam dodana opcje z wykrywaniem longPressa
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(hitTest:withEvent:)]; [mapView addGestureRecognizer:longPress ];
i metode do przechwytywania zdarzenia:
- (void)hitTest:(CGPoint)point withEvent:(UIEvent *)event { if(licz%2!=0){ CLLocationCoordinate2D coord= [mapView convertPoint:point toCoordinateFromView:self.mapView]; nowePunkty *newP=[[nowePunkty alloc]create:coord.latitude:coord.longitude:@"new":@"sadas"]; [mapView addAnnotation:newP]; NSLog(@"%f,%f",coord.latitude,coord.longitude); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Dodano nowy punkt!" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; [alert release]; } licz++; }
Jednak nslog wyswietla zupelnie inne wspolrzedne niz te ktore powinny byc w danym miejscu, ogolnie to punkt pojawia sie albo nie tam gdzie trzeba, albo wcale go nie ma;/
Dodatkowo mam jeszcze problem poniewaz przy dlugim tapnieciu metoda pojawiala sie 2 razy ( raz jak wcisnalem i 2gi raz jak puscilem ) czy da sie to jakos mniej łopatologicznie roziwazac niz uzywajac licznika, tak jak ja to zrobilem? I jak poprawic dodawanie nowych punktow?