Pau*_*aul 2 objective-c mkcoordinateregion mkmapview
我想知道如何使这个代码工作:当我点击一个单元格时,我调用DetailViewController,这是一个坐标为旧金山的地图.但我的地图只显示"世界"地图,不要去我设置的地区,你知道我怎么能用"我的"坐标开始吗?
这是我的代码:
#import "DetailViewController.h"
@implementation DetailViewController
@synthesize mapView;
- (void) gotoLocation {
NSLog(@"allo");
//start off in San Francisco
MKCoordinateRegion region;
region.center.latitude = 37.786996;
region.center.longitude = -122.440100;
region.span.latitudeDelta = 0.112872;
region.span.longitudeDelta = 0.109863;
[self.mapView setRegion:region animated:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self gotoLocation];
}
- (void)dealloc {
[super dealloc];
[mapView release];
}
- (void)viewDidUnload {
[super viewDidUnload];
self.mapView = nil;
}
@end
Run Code Online (Sandbox Code Playgroud)
谢谢
保罗
- (void)viewDidLoad{
[super viewDidLoad];
// define span for map: how much area will be shown
MKCoordinateSpan span;
span.latitudeDelta = 0.002;
span.longitudeDelta = 0.002;
// define starting point for map
CLLocationCoordinate2D start;
start.latitude = 37.786996;
start.longitude = 0.109863;
// create region, consisting of span and location
MKCoordinateRegion region;
region.span = span;
region.center = start;
// move the map to our location
[self.mapView setRegion:region animated:YES];
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
4240 次 |
| 最近记录: |