簡體   English   中英

無法獲取Mapkit類,要編譯的方法

[英]Can't get Mapkit class, method to compile

由於-(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];
}

能否請您告訴我克服該問題並讓程序進行編譯需要做什么?

謝謝。

嘗試

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

您的剪切和粘貼錯過了userLocationserLocation

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM