我有一个地图视图控制器(UIViewController,MKMapView)及其委托(HCIResultMapViewController)。mkannotation中的自定义数据变量
我希望在这部分有以下功能。
1)。我希望用我的定制NSObject的,让我能与像标题,副标题等基本实体沿着别人的信息关联起来
因此,根据我的需要我编写如下
在HCIResultMapViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
_houseList = [[_resultList objectForKey:@"result"] objectForKey:@"listings"];
// NSLog([_houseList description]);
int i = 0;
for (NSDictionary *house in _houseList) {
HCIAnnotationViewController *annotation = [[HCIAnnotationViewController alloc]
initwithHouse:house];
[_mapView addAnnotation:annotation];
// NSLog(@"asdjhasdjsajdhaksdjghasdasdjahsdahskvdka");
self.currIdentifier = i;
i++;
}
[_mapView setShowsUserLocation:NO];
}
其他委托功能
-(void) mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
for (NSObject<MKAnnotation> *annotation in _mapView.selectedAnnotations) {
NSLog(@"hellomaster");
NSLog(annotation.title);
if ([annotation isKindOfClass:[HCIAnnotationViewController class]]) {
NSLog(@"hellomaster");
}
}
最后一个
-(MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
NSString *identifier = @"currIdentifier";
MKPinAnnotationView *annotationView =
(MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.tag = self.currIdentifier;
// Create a UIButton object to add on the
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[annotationView setRightCalloutAccessoryView:rightButton];
/*
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[leftButton setTitle:annotation.title forState:UIControlStateNormal];
[annotationView setLeftCalloutAccessoryView:leftButton];
*/
return annotationView;
}
但我看到类等价失败。你能告诉我我做错了什么吗?
我想我想要的,简单来说,我怎么能发送一些数据(NSDictionary *)以及注释,以便我可以随时检索它?
请不要标记为重复的问题左右。我尝试了很多问题,谷歌搜索等,但找不到合适的解决方案。
你想创建自定义注释..例如标题,副标题? – iPatel 2013-03-11 12:24:38
没有。我希望我的注释包含一个NSDictionary *以及诸如标题,副标题之类的实体。 – 2013-03-11 12:26:38