2011-08-28 85 views
0

無法獲得,因爲在 錯誤的代碼編譯 - (空)的MapView:(*的MKMapView)的MapView didUpdateUserLocation:(MKUserLocation *)用戶位置無法獲得Mapkit類,方法編譯

方法。 Xcode的4說,「U」是一個未聲明的標識符,因此是「*」

這裏是.m文件代碼:

#import "WhereamiAppDelegate.h" 

@implementation WhereamiAppDelegate 


@synthesize window=_window; 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions 
{ 
    // Create location manager object 
    locationManager = [[CLLocationManager alloc]init]; 

    // There will be a warning from this line of code, ignore it for now 
    [locationManager setDelegate:self]; 

    // We want all results from the Location Manager 
    [locationManager setDistanceFilter:kCLHeadingFilterNone]; 

    // And we want it to be as accurate as possible 
    // regardless of how much power it takes 
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; 

    // [locationManager startUpdatingLocation]; 
    [worldView setShowsUserLocation:YES]; 

    // Tell our manager to start looking for its location immediately 
    [locationManager startUpdatingLocation]; 

    [self.window makeKeyAndVisible]; 
    return YES; 
} 

- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
      fromLocation:(CLLocation *)oldLocation 
{ 
    NSLog(@"%@", newLocation); 
} 

- (void)locationManager:(CLLocationManager *)manager 
     didFailWithError:(NSError *)error 
{ 
    NSLog(@"Could not find location: %@", error); 
} 

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation 
{ 
    CLLocationCoordinate2D loc = [u coordinate]; 
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250); 
    [worldView setRegion:region animated:YES]; 
} 

能否請你告訴我,我需要做的克服這個問題並讓程序編譯?

謝謝。

回答

0

嘗試

- (void)mapView:(MKMapView*)mapView didUpdateUserLocation:(MKUserLocation*)userLocation 
{ 
    CLLocationCoordinate2D loc = [userLocation coordinate]; 
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250); 
    [worldView setRegion:region animated:YES]; 
} 

你剪切和粘貼無緣serLocation 用戶位置

+0

哈,我很尷尬!但是,謝謝你,現在它工作! – pdenlinger