Iphone Can';不要让我的地图上出现标注pin

Iphone Can';不要让我的地图上出现标注pin,iphone,objective-c,mkannotation,Iphone,Objective C,Mkannotation,现在,在我完成剩余的作业之前,我正在尝试测试在地图上标注图钉的概念。分配说明中说不需要CLLocationManager。到目前为止,我已经尝试在mkAnnotate类的特定实例上调用mkAnnotate pin。我尝试调用委托方法,并尝试手动输入坐标,但没有成功。在后面的作业中,我想让程序根据分段按钮的选择放置一个管脚并缩放到某个位置,但现在我只想知道如何放置管脚。这里是我的ViewContoller.m文件中的代码 #import "GoThereViewController.h" @in

现在,在我完成剩余的作业之前,我正在尝试测试在地图上标注图钉的概念。分配说明中说不需要CLLocationManager。到目前为止,我已经尝试在mkAnnotate类的特定实例上调用mkAnnotate pin。我尝试调用委托方法,并尝试手动输入坐标,但没有成功。在后面的作业中,我想让程序根据分段按钮的选择放置一个管脚并缩放到某个位置,但现在我只想知道如何放置管脚。这里是我的ViewContoller.m文件中的代码

#import "GoThereViewController.h"

@interface GoThereViewController ()

@end

@implementation GoThereViewController
//@synthesize segment;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [world setShowsUserLocation:YES]; 

    //Location array declarations
    //GoThereMapPoint *gtET = [[GoThereMapPoint alloc]initWithCoordinate:CLLocationCoordinate2DMake(39.774033,-86.172754) title:@"Engineering & Technology Building"];
    GoThereMapPoint *gtEmpireState = [[GoThereMapPoint alloc]initWithCoordinate:CLLocationCoordinate2DMake(40.7483786347046,-73.98555994033813) title:@"Empire State Building"];  
    GoThereMapPoint *gtTajMahal = [[GoThereMapPoint alloc]initWithCoordinate:CLLocationCoordinate2DMake(27.171171855453526,78.04248690605164) title:@"Taj Mahal"];


    //Put in array.
    //aryGoThere = [NSArray arrayWithObjects:gtET,gtEmpireState,gtTajMahal, nil];
    // Do any additional setup after loading the view from its nib.


}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


//Somehow this method calls the annotate and zoom method
-(void)didUpdateToLocation:(CLLocation *)newLocation 
              fromLocation:(CLLocation *)oldLocation
{
    GoThereMapPoint *gtET = [[GoThereMapPoint alloc]initWithCoordinate:CLLocationCoordinate2DMake(39.774033,-86.172754) title:@"Engineering & Technology Building"];    
    [self foundLocation:newLocation];
}

//Create instance of location and zoom to it
-(void)foundLocation:(CLLocation *)loc
{
    //Create instance of location
    CLLocationCoordinate2D coord = [loc coordinate];
    //Add pin

    GoThereMapPoint *mp = [[GoThereMapPoint alloc]initWithCoordinate:coord title:@"test"]; 
     [world addAnnotation:mp];    //Zoom to location
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord,500,500);
    [world setRegion:region animated:YES];
}
如果您还需要什么帮助,请务必告诉我


编辑:忘记提到MKAnnotate类的名称是GoThereViewController。

首先确保实际调用了
updateLocations
方法。该方法现在已被弃用,取而代之的是:

-(无效)位置管理器:(CLLocationManager*)管理器更新位置:(NSArray*)位置
{
}

您应该从那里调用
foundLocation
方法。

请参阅以下链接: