将用户个人资料照片动态地映射到ios中

时间:2014-03-15 07:48:52

标签: ios iphone google-maps ios7

我想在 iOS 中显示要映射的所有用户照片。这里,所有用户照片都来自服务器,通过网络服务。

让我附上屏幕显示我想要实现的目标以获得更好的想法。enter image description here

例如pin图像: enter image description here

所以我想为所有用户创建自定义引脚,以便在iphone应用程序的地图中显示。

任何人都可以重定向我在ios中完成上述任务。

提前致谢。

1 个答案:

答案 0 :(得分:3)

我正在粘贴我的一个项目的代码。但你会得到主要的想法。我正在处理一堆或不同的商店,所以我在每个注释上添加标签。我也在使用SDWebImage库动态加载远程图像。 绿色图钉是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;
}

enter image description here

相关问题