我的地圖別針可以非常密集地填充,因此當選擇別針時,標註會彈出,但大部分都會被所有其他地圖別針遮擋 - 我可以將地圖別針到前面它有一個代表選定的地圖引腳(未點擊標註,選定的引腳)。MKAnnotation - 地圖別針標註在其他地圖別針後面彈出
任何有關工作的建議?
我的地圖別針可以非常密集地填充,因此當選擇別針時,標註會彈出,但大部分都會被所有其他地圖別針遮擋 - 我可以將地圖別針到前面它有一個代表選定的地圖引腳(未點擊標註,選定的引腳)。MKAnnotation - 地圖別針標註在其他地圖別針後面彈出
任何有關工作的建議?
UICallout視圖是MKAnnotationView的子視圖。所以,我想如果你將Map ping帶到前面,UICAlloutView也會在那裏。
如果您正在使用自定義註釋視圖,則可以爲所選屬性添加一個觀察者,該選擇屬性將在選擇該對象時充當代表的角色。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
MKAnnotation *annview = ...code to either dequeue or create new object...
[annview addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:@"selectedmapannotation"];
return annview;
}
那麼你就可以
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context;
監測選擇的狀態由Mugunth庫馬爾聯答案也會給你所期望的結果,它只是你做代表提到像你的問題的功能。
編輯:
這裏的observeValueForKeyPath的內容的例子:ofObject變化:context:方法
NSString *action = (NSString*)context;
if([action isEqualToString:@"selectedmapannotation"]){
BOOL annotationAppeared = [[change valueForKey:@"new"] boolValue];
MKAnnotationView *ann = (MKAnnotationView *)object;
if (annotationAppeared) {
// do something with the annotation when it is selected
}
else {
// do something with the annotation when it is de-selected
}
}
你怎麼把UICalloutView到前面編程? – si28719e 2010-06-17 04:21:49