2013-12-12 33 views
0

我有地圖視圖,當我點擊地圖上的任何地方時,我隱藏了導航欄。在地圖上點按手勢

我目前使用的是UITapGestureRecognizer手勢。我如何檢測他們是否碰到了註釋視圖,而不是從這個手勢中隱藏工具欄?

回答

1

您可以將Tag屬性賦予視圖。而且,如果你TapGestureRecognizer方法

檢查視圖的標籤,並根據您可以執行自定義操作

- (void)tapImagesLike:(UITapGestureRecognizer*)recognizer{ 
    UIView *View = recognizer.view; 
    //use imageView.tag as the id 
} 
1

您可以使用MKMapVie的委託方法用於此目的

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 

這委託方法將在用戶選擇註釋時調用。使用此didSelectAnnotationView作爲

-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 

{   
    //annotation selected. do the stuff here for hiding toolbar 
} 

設置你的MapView的代表也

mView.delegate = self;