与Instagram照片地图的照片地图
我正在尝试创build一个类似Instagrams照片地图的照片地图。
照片地图: http : //i.stack.imgur.com/B0wDa.jpg
我怎样才能得到的图像(从parsing加载)的注释,就像上面的截图?
到目前为止,这就是MapViewController.m
[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) { PFQuery *query = [PFQuery queryWithClassName: @"HomePopulation"]; [query whereKey:@"geopoint" nearGeoPoint:geoPoint withinKilometers:3000]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { for (PFObject *object in objects) { PFGeoPoint *thePoint = [object objectForKey:@"geopoint"]; latitude = thePoint.latitude; longitude = thePoint.longitude; NSLog(@" Hej %f, %f", latitude, longitude); CLLocationCoordinate2D annotationCoordinate = CLLocationCoordinate2DMake(latitude, longitude); Annotation *annotation = [[Annotation alloc] init]; annotation.coordinate = annotationCoordinate; annotation.title = [object objectForKey:@"discovery"]; annotation.subtitle = [object objectForKey:@"location"]; PFFile *image = [object objectForKey:@"imageFile"]; annotation.imageView.file = image; [annotation.imageView loadInBackground]; [self.theMap addAnnotation:annotation]; [self.theMap setCenterCoordinate:annotation.coordinate animated:YES]; [self setNeedsStatusBarAppearanceUpdate]; } } }]; }];
任何帮助赞赏。 马尔科
在此讨论的帮助下: 具有相同图像的自定义注释
我出来了这个:
代码如下:
MapViewController.h #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> #import <Parse/Parse.h> @interface MapViewController : UIViewController <MKMapViewDelegate> @property double latitude; @property double longitude; @end MapViewController.m - (void)viewDidLoad { [super viewDidLoad]; [self.navigationController setNavigationBarHidden:YES animated:YES]; self.theMap.delegate = self; self.theMap.showsUserLocation = YES; [PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) { PFQuery *query = [PFQuery queryWithClassName: @"HomePopulation"]; [query whereKey:@"geopoint" nearGeoPoint:geoPoint withinKilometers:1000]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { for (PFObject *object in objects) { PFGeoPoint *thePoint = [object objectForKey:@"geopoint"]; latitude = thePoint.latitude; longitude = thePoint.longitude; NSLog(@" Hej %f, %f", latitude, longitude); CLLocationCoordinate2D annotationCoordinate = CLLocationCoordinate2DMake(latitude, longitude); Annotation *annotation = [[Annotation alloc] init]; annotation.coordinate = annotationCoordinate; annotation.title = [object objectForKey:@"discovery"]; annotation.subtitle = [object objectForKey:@"location"]; annotation.objectID = object.objectId; [self.theMap addAnnotation:annotation]; } } }]; }]; //[self.theMap reloadInputViews]; } - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { static NSString *identifier = @"theLocation"; if ([annotation isKindOfClass:[Annotation class]]) { MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[self.theMap dequeueReusableAnnotationViewWithIdentifier:identifier]; if (annotationView == nil) { annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; } else { annotationView.annotation = annotation; } annotationView.enabled = YES; //annotationView.canShowCallout = YES; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(-40, -100, 100, 100)]; imageView.contentMode = UIViewContentModeScaleAspectFit; NSString *id = [(Annotation *)annotationView.annotation objectID]; PFQuery *query = [PFQuery queryWithClassName:@"HomePopulation"]; [query getObjectInBackgroundWithId:[NSString stringWithFormat:@"%@", id] block:^(PFObject *object, NSError *error) { PFFile *file = [object objectForKey:@"imageFile"]; [file getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { imageView.image = [UIImage imageWithData:data]; }]; }]; annotationView.image = [UIImage imageNamed:@"pointer"]; [annotationView addSubview:imageView]; return annotationView; } return nil; } Annotation.h #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> #import <Parse/Parse.h> @interface Annotation : NSObject <MKAnnotation> @property (nonatomic) CLLocationCoordinate2D coordinate; @property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *subtitle; @property (nonatomic, copy) NSString *objectID; @end
- 如何authentication后从雅虎redirect到我的IOS应用程序?
- iOSconfiguration和authentication – 将撤销/续订效果App Store应用程序?
- UIScrollView contentOffset在另一个视图推送后更改
- URLSession didCompleteWithError无错误
- 如何在swift中添加彩色边框气泡标注?
- 如何获取应用程序版本并构buildiOS PhoneGap应用程序?
- 为UIImagePicker添加圆形裁剪组件?
- TableViewをDRYな设计にリファクタリングした话
- UICollectionView VS UITableview