0
我想知道是否有人知道在mapview中是否有搜索功能? 我希望能夠使用UISearchbar搜索/過濾註釋,就像在tableview UI中完成一樣。註釋從plist中加載。 會很高興爲任何提示或幫助,搜索遍及我找不到任何東西...在地圖上搜索註釋
我想知道是否有人知道在mapview中是否有搜索功能? 我希望能夠使用UISearchbar搜索/過濾註釋,就像在tableview UI中完成一樣。註釋從plist中加載。 會很高興爲任何提示或幫助,搜索遍及我找不到任何東西...在地圖上搜索註釋
過濾它們的名稱與謂詞。例如:
NSArray *filteredAnnotations = [self.mapView.annotations filterUsingPredicate:[NSPredicate predicateWithFormat:@"SELF.name beginswith[dc] %@",userInput]];
然後全部刪除,然後使用已過濾數組中的註釋重新加載映射。
[self.mapView removeAnnotations:self.mapView];
self.mapView.annotations = filteredAnnotations;
觸發從UISearchBar
的代表的方法searchBarTextDidEndEditing:
此代碼。如果您不希望搜索的表預覽,請使用UISearchBar而不使用UISearchBarDisplayController。
或者像rckoenes說的那樣,放大過濾的註釋的區域。在SO中可能有代碼。
那麼你可以做的是搜索從plist加載的項目數組。然後只需在'MKMapView'上繪製找到的項目,放大以僅顯示地圖上的註釋。 – rckoenes 2013-03-26 15:09:31