小编jer*_*bus的帖子

如何将UIViewController中的纬度和经度值传递给MKMapView?

我有一个包含三个UIButton的详细视图,每个UIButtons都会将不同的视图推送到堆栈.其中一个按钮连接到MKMapView.按下该按钮时,我需要将详细视图中的纬度和经度变量发送到地图视图.我正在尝试在IBAction中添加字符串声明:

- (IBAction)goToMapView {

MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil]; 

mapController.mapAddress = self.address;
mapController.mapTitle = self.Title;

mapController.mapLat = self.lat;
mapController.mapLng = self.lng;

//Push the new view on the stack
[[self navigationController] pushViewController:mapController animated:YES];
[mapController release];
//mapController = nil;
Run Code Online (Sandbox Code Playgroud)

}

在我的MapViewController.h文件中,我有:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import "DetailViewController.h"
#import "CourseAnnotation.h"

@class CourseAnnotation;

@interface MapViewController : UIViewController <MKMapViewDelegate>
{
IBOutlet MKMapView *mapView;
NSString *mapAddress;
NSString *mapTitle;
NSNumber *mapLat;
NSNumber *mapLng;
}

@property (nonatomic, retain) IBOutlet MKMapView *mapView;
@property (nonatomic, retain) NSString *mapAddress; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiviewcontroller mkcoordinateregion mkmapview

2
推荐指数
1
解决办法
4266
查看次数