Currently, i'm using SWRevealViewController
to create a sidebar and google map api
for my project.
https://github.com/John-Lluch/SWRevealViewController
Here's the problem. Everytime I switch between ViewControllers
using the sidebar and back to the MapViewController
which contains GMSMapView
, the GMSMapView
is reloaded to my location (I set it in my viewDidLoad
method).
How can I prevent MapViewController
reloads everytime like that ?
What I've tried so far:
Make the MapViewController
becomes a singleton and set it to destinationViewController
but it doesn't work. All I got is a black screen.
my code for the custom segue
:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] )
{
SWRevealViewControllerSegue* rvcs = (SWRevealViewControllerSegue*) segue;
SWRevealViewController* rvc = self.revealViewController;
rvcs.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
{
if ([segue.identifier isEqualToString:@"SegueToMapViewController"])
{
dvc = [MapViewController sharedMap]; //singleton
}
UINavigationController* nc = [[UINavigationController alloc] initWithRootViewController:dvc];
[nc setNavigationBarHidden:YES];
[nc setToolbarHidden:YES];
[rvc setFrontViewController:nc animated:YES];
};
}
}