【发布时间】:2012-01-17 19:57:57
【问题描述】:
好的,这实际上是一个线程中的三个不同的问题:
1) 我正在使用:
- (void)viewDidLoad
{
[super viewDidLoad];
[mapView setFrame :CGRectMake(-100,-100,520,520)];
[mapView setAutoresizesSubviews:true];
mapView.showsUserLocation = YES;
locManager = [[CLLocationManager alloc] init];
locManager.delegate = self;
[locManager startUpdatingLocation];
[locManager startUpdatingHeading];
[bt_toolbar setEnabled:YES];
}
- (IBAction) CreatePicture
{
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(mapView.userLocation.coordinate.latitude, mapView.userLocation.coordinate.longitude);
CGPoint annPoint = [self.mapView convertCoordinate:coord toPointToView:self.mapView];
mapPic = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pic.png"]];
mapPic.frame = CGRectMake(annPoint.x, annPoint.y, 32, 32);
[self.view addSubview:macPic];
}
使用 GCRectMake 在用户坐标上放置图像,但遗憾的是图像没有放置在正确的位置:
如果我移动地图,图片将始终以与用户位置完全相同的偏移量放置。我错过了什么?它不应该直接放在用户上方吗?我猜我首先给 mapView 的偏移量(-100,-100)是造成这种情况的原因(我在下面有一个工具栏,因此是偏移量)。
2) 我的 iOS 5 模拟器表现得很疯狂,出于某种原因将我的位置放在凤凰城的格伦代尔(不应该在库比蒂诺吗??),并且表现得像我在向东移动一样;不过,在我的 iPhone 4 中一切正常(除了图片的位置不正确)。有什么想法吗?
3) 我一直在考虑改用注释,但我听说它们是静态的(我真的需要它们是动态的)。这是真的吗?
谢谢!
【问题讨论】:
-
您能否将添加 mapPic 的部分包含到您的视图层次结构中?听起来您可能正在使用 mapView 的坐标系,但将 mapPic 放在具有不同坐标系的超级视图(可能是视图控制器的视图)中。
-
您好,感谢您的回复。就是一个简单的addSubView,就加进去了。
标签: iphone ios ios5 ios-simulator mapkit