【问题标题】:Can't get Mapkit class, method to compile无法获取 Mapkit 类,编译方法
【发布时间】:2011-08-28 22:42:15
【问题描述】:

由于代码中的错误,无法编译代码 - (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];
}

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

谢谢。

【问题讨论】:

    标签: ios4 xcode4 mapkit


    【解决方案1】:

    试试

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

    您的剪切和粘贴错过了 userLocationserLocation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-12
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 2016-03-11
      • 1970-01-01
      相关资源
      最近更新 更多