【发布时间】:2012-08-13 23:25:26
【问题描述】:
我一直在研究 MKMapView 很长一段时间试图更熟悉它,但我遇到了一个问题。
我的 MapView 填充了两个引脚,当我按下它们时,它们有各自的注释。我还有一个按钮,可以将我带到一个带有 UlLabels 的新 UIView,该 UIView 将加载来自数组的数据。
看着我的控制台,我注意到数据正在通过,但不是仅用于引脚,而是我选择了加载所有这些数据,然后显示最后一个。
这是我用来为下一个视图加载数据的方法的代码:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:addAnnotation reuseIdentifier:@"currentloc"];
if(annView.tag = 0) {
GSStore * theStore = [globalCMS getStoreById:1];
NSUserDefaults * prefs = [NSUserDefaults standardUserDefaults];
int storeid = theStore.storeid;
[prefs setInteger:storeid forKey:@"selectedstore"];
NSLog(@"%@", theStore.name);
storeName.text = [NSString stringWithFormat:@"%@", theStore.name];
storeCS.text = [NSString stringWithFormat:@"%@,%@", theStore.city, theStore.state];
storeHours.text = [NSString stringWithFormat:@"%@", theStore.hours];
storePhone.text = [NSString stringWithFormat:@"%@", theStore.phone];
storeAddress.text = [NSString stringWithFormat:@"%@", theStore.address];
storeCSZ.text = [NSString stringWithFormat:@"%@,%@ %@", theStore.city, theStore.state, theStore.zip];
storeWebsite.text = [NSString stringWithFormat:@"%@", theStore.website];
}
if(annView.tag = 1){
GSStore * theStore = [globalCMS getStoreById:2];
NSUserDefaults * prefs = [NSUserDefaults standardUserDefaults];
int storeid = theStore.storeid;
[prefs setInteger:storeid forKey:@"selectedstore"];
NSLog(@"%@", theStore.name);
storeName.text = [NSString stringWithFormat:@"%@", theStore.name];
storeCS.text = [NSString stringWithFormat:@"%@,%@", theStore.city, theStore.state];
storeHours.text = [NSString stringWithFormat:@"%@", theStore.hours];
storePhone.text = [NSString stringWithFormat:@"%@", theStore.phone];
storeAddress.text = [NSString stringWithFormat:@"%@", theStore.address];
storeCSZ.text = [NSString stringWithFormat:@"%@,%@ %@", theStore.city, theStore.state, theStore.zip];
storeWebsite.text = [NSString stringWithFormat:@"%@", theStore.website];
}
if (annView.tag = 2) {
GSStore * theStore = [globalCMS getStoreById:3];
NSUserDefaults * prefs = [NSUserDefaults standardUserDefaults];
int storeid = theStore.storeid;
[prefs setInteger:storeid forKey:@"selectedstore"];
NSLog(@"%@", theStore.name);
storeName.text = [NSString stringWithFormat:@"%@", theStore.name];
storeCS.text = [NSString stringWithFormat:@"%@,%@", theStore.city, theStore.state];
storeHours.text = [NSString stringWithFormat:@"%@", theStore.hours];
storePhone.text = [NSString stringWithFormat:@"%@", theStore.phone];
storeAddress.text = [NSString stringWithFormat:@"%@", theStore.address];
storeCSZ.text = [NSString stringWithFormat:@"%@,%@ %@", theStore.city, theStore.state, theStore.zip];
storeWebsite.text = [NSString stringWithFormat:@"%@", theStore.website];
}
}
【问题讨论】:
标签: ios mkmapview mkannotation