2013-01-18 23 views
0

蔭試圖顯示地圖套件和我做了以下內容: MapViewController.h表達不不分配,mapkit

#import <UIKit/UIKit.h> 
#import <MapKit/MapKit.h> 
#import <QuartzCore/QuartzCore.h> 
@interface SiteViewController : UIViewController <MKMapViewDelegate> 

@property (assign, nonatomic)  MKCoordinateRegion region; 
@property (strong, nonatomic)  IBOutlet MKMapView *googleMap; 

@end 

MapViewController.m

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    // Set propertiesfor the mapView 
    self.region.center.latitude   = 43.62862 ; // expression is not assigned 
    self.region.center.longitude  = -79.331245;// expression is not assigned 
    self.region.span.longitudeDelta  = 0.01f;  // expression is not assigned 
    self.region.span.longitudeDelta  = 0.01f;  // expression is not assigned 
    [self.googleMap setMapType:MKMapTypeStandard]; 
    [self.googleMap setZoomEnabled:YES]; 
    [self.googleMap setScrollEnabled:YES]; 
    [self.googleMap setRegion:self.region animated:YES]; 


    MKPointAnnotation *pin = [[MKPointAnnotation alloc] init]; 
    pin.coordinate = region.center; 
    [self.googleMap addAnnotation:pin]; 
} 

我越來越

表達式未分配

我不明白這一點。有人可以得到解釋並讓我擺脫這種麻煩。

+1

我想你會發現這個類似的問題有所幫助:http://stackoverflow.com/questions/7074405/expression-is-not-assignable-problem-assigning-float-作爲-加總兩其他-FL –

回答

0

您需要通過region屬性或方法- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated;來設置mapview區域。

試試這個:

CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(43.62862, -79.331245); 

[self.mapView setRegion:MKCoordinateRegionMake(coordinate, MKCoordinateSpanMake(0.01f, 0.01f))];