Question was solved! See the code at the bottom.
I'd like to pass some data between 2 controllers. I have MainViewController class where GoogleMap is loaded. On click at custom info window for each GMap's marker I want to open new window with place details.
My storyboard is:
Segue was named: showPlaceDetails:
Several methods was written:
- (void) mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker {
[self performSegueWithIdentifier:@"showPlaceDetails" sender: nil];
}
(I also tried to use sender: [marker snippet]
).
My prepareForSegue method:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showPlaceDetails"]) {
//[[segue destinationViewController] setDelegate:self];
PlaceDetailsViewController *destViewController = segue.destinationViewController;
//Pass some data
}
}
But I got the message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (RelaxInKZViewController) has no segue with identifier 'showPlaceDetails''
I did these steps:
- Add New View Controller on storyboard.
- Add Objective-C Class called PlaceDetailsViewController.
- Change custom class of newly added VC to "PlaceDetailsViewController"
- Add that code
- Clear Simulator's data and clean project
And nothing. I hope you can help me :) Thx, Artem.
Mr_bem has adviced me to refuse segues and use pushViewController method. It's good!
UIStoryboard *iPhoneStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
PlaceDetailsViewController *destViewController = [iPhoneStoryboard instantiateViewControllerWithIdentifier:@"PlaceDetailsViewController"];
destViewController.placeData = marker.placeData;
[self.navigationController pushViewController:destViewController animated:NO];