将用户配置文件照片动态放置到ios中的映射pin
我想在iOS中显示所有要映射的用户照片。在这里,所有用户照片都是通过web服务从服务器获取的 让我附加屏幕显示我想要实现的目标,以获得更好的想法 e、 g pin的图像: 所以我想为所有用户创建如上所述的自定义pin,以显示在iphone应用程序的地图中 任何人都可以让我在ios中完成上述任务将用户配置文件照片动态放置到ios中的映射pin,ios,iphone,google-maps,ios7,Ios,Iphone,Google Maps,Ios7,我想在iOS中显示所有要映射的用户照片。在这里,所有用户照片都是通过web服务从服务器获取的 让我附加屏幕显示我想要实现的目标,以获得更好的想法 e、 g pin的图像: 所以我想为所有用户创建如上所述的自定义pin,以显示在iphone应用程序的地图中 任何人都可以让我在ios中完成上述任务 提前感谢。我正在粘贴我的一个项目中的代码。但你会明白主要的意思。我处理的是一堆或不同的商店,所以我在每个注释上添加标签。我还使用SDWebImage库动态加载远程图像。 绿色pin是mapPin,圆圈图
提前感谢。我正在粘贴我的一个项目中的代码。但你会明白主要的意思。我处理的是一堆或不同的商店,所以我在每个注释上添加标签。我还使用SDWebImage库动态加载远程图像。 绿色pin是mapPin,圆圈图像是从服务器动态加载的
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKAnnotationView *aView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"mapPin"];
if(aView){
aView.annotation = annotation;
} else {
aView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"mapPin"];
ESMapViewAnnotation *newAnnotation=(ESMapViewAnnotation *)annotation;
ZBStore *s=(ZBStore *)[dataArray objectAtIndex:newAnnotation.tag];
NSString *iURL=s.Icon;
UIImageView *imageView = [[UIImageView alloc] init];
[imageView setImageWithURL:[NSURL URLWithString:iURL]
placeholderImage:[UIImage imageNamed:@"Question.jpg"]];
imageView.layer.borderWidth=1;
imageView.layer.borderColor=[[UIColor whiteColor]CGColor];
imageView.backgroundColor=s.BColor;
CGRect f= CGRectMake(2,2,46,43);
[imageView setFrame:f];
imageView.layer.cornerRadius=22.0;
imageView.layer.masksToBounds=YES;
aView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[aView addSubview:imageView];
aView.enabled = YES;
aView.canShowCallout = YES;
aView.image = [UIImage imageNamed:@"gPin2.png"];//here we use a nice image instead of the default pins
}
return aView;
//return nil;
}
请注意,此代码仅在为某些注释X创建注释视图(alloc+init)时才设置图像。如果该视图随后对其他注释Y重复使用(如果出列返回先前创建的视图),则注释Y将显示注释X的图像。谢谢,但现在无法点击pin点…打开呼叫…请建议。