Ipad MKMapView未调用委托方法
我试图在地图上放置图钉,但它并没有调用委托方法Ipad MKMapView未调用委托方法,ipad,annotations,mkmapview,Ipad,Annotations,Mkmapview,我试图在地图上放置图钉,但它并没有调用委托方法 (MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{ 我的应用程序是通用的,所以当我使用iPhone时,它会正确地调用委托方法,但当我使用iPad时,则不会调用委托方法。 代码如下: (MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{ 静态NSString*标识符=@“MachineLocation”; if([annotation IsKind
- (MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
- (MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{
静态NSString*标识符=@“MachineLocation”;
if([annotation IsKindof类:[MachineLocation类]]){ } 返回nil;}
NSString *tempString;
for(NSMutableArray *array in appDelegate.globalVehicleInfoArray) {
for (VehicleInfo *vehicleInfo in array) {
for (WeatherCondition *weather in appDelegate.globalWeatherConditionArray) {
if ([weather.weatherID isEqualToString:[vehicleInfo vehicleID]]) {
tempString = [weather weatherTempC];
// NSLog(@"weather id matched");
}
}
NSString *name = [vehicleInfo vehicleName];
NSString *machineDescription = [NSString stringWithFormat:@"%@ %@ C", [vehicleInfo vehicleLastUpdate], tempString];
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
CLLocationCoordinate2D coordinate;
coordinate.latitude = [[vehicleInfo vehicleLastPositionY] doubleValue];
coordinate.longitude = [[vehicleInfo vehicleLastPositionX] doubleValue];
NSLog(@"%f , %f", coordinate.latitude, coordinate.longitude);
MachineLocation *location = [[MachineLocation alloc] initWithId:[vehicleInfo vehicleID] :name description:machineDescription coordinate:coordinate];
// annotation.coordinate = coordinate;
[self.mapView addAnnotation:location];
}
}
您是否为iPad使用单独的xib?地图视图是在xib中还是以编程方式创建的?代理插座是否在iPad的xib中正确连接?在iPad上,在view中,它是否实际通过循环并添加注释?注释是否显示为红色针脚?我收到了相同的错误,您是否找到了原因?我通过创建一个新类并在那里再次编写相同的代码来管理它。它对我很有用
NSString *tempString;
for(NSMutableArray *array in appDelegate.globalVehicleInfoArray) {
for (VehicleInfo *vehicleInfo in array) {
for (WeatherCondition *weather in appDelegate.globalWeatherConditionArray) {
if ([weather.weatherID isEqualToString:[vehicleInfo vehicleID]]) {
tempString = [weather weatherTempC];
// NSLog(@"weather id matched");
}
}
NSString *name = [vehicleInfo vehicleName];
NSString *machineDescription = [NSString stringWithFormat:@"%@ %@ C", [vehicleInfo vehicleLastUpdate], tempString];
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
CLLocationCoordinate2D coordinate;
coordinate.latitude = [[vehicleInfo vehicleLastPositionY] doubleValue];
coordinate.longitude = [[vehicleInfo vehicleLastPositionX] doubleValue];
NSLog(@"%f , %f", coordinate.latitude, coordinate.longitude);
MachineLocation *location = [[MachineLocation alloc] initWithId:[vehicleInfo vehicleID] :name description:machineDescription coordinate:coordinate];
// annotation.coordinate = coordinate;
[self.mapView addAnnotation:location];
}
}