无法获取Mapkit类,编译方法

时间:2011-08-28 22:42:15

标签: ios4 xcode4 mapkit

由于错误导致无法获取编译代码 - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation

方法。 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];
}

您能告诉我我需要做些什么来克服这个问题并让程序编译?

谢谢。

1 个答案:

答案 0 :(得分:0)

尝试

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

您的剪切和粘贴错过了 userLocation serLocation