Unable to pass variables from one view to another
I have a detail view that includes three UIButtons, each of which pushes a different view on to the stack. One of the buttons is connected to a MKMapView. When that button is pushed I nee开发者_开发百科d to send the latitude and longitude variables from the detail view to the map view. I'm trying to add the string declaration in the IBAction:
- (IBAction)goToMapView {
MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil];
mapController.address = self.address;
mapController.Title = self.Title;
mapController.lat = self.lat;
mapController.lng = self.lng;
//Push the new view on the stack
[[self navigationController] pushViewController:mapController animated:YES];
[mapController release];
mapController = nil;
}
But I get this when I try to build: 'error: incompatible types in assignment' for both lat and lng variables. So my questions are am I going about passing the variables from one view to another the right way? And does the MKMapView accept latitude and longitude as a string or a number?
You seem to be doing it fine, but as the compiler error says, your variables have incompatibles types. Make sure that self.lat
and mapController.lat
have the same types (same for the lng
variables).
精彩评论