ios - Why is viewDidLoad being called twice -


i have gps app uses google maps handle location based events. app handles location events within app , not switch googles own google maps app.

the storyboards can seen in image below. enter image description here

in app have main map view (my map view controller in storyboard) displays users current location list of marked locations around user on map. map contains button take user list of marked points (list of points table view controller). selecting of list points takes them detailed description of point (log point). , clicking "view on map" button on view takes them last view (submit point map view controller) can see point zoomed in on views map.

both map views (my map view controller , submit point map view controller) use similar code listed below. however, when run run code , "submit point map view controller", views viewdidload method executed twice have noticed while stepping through code. causes 2 views load, 1 right after other. can see happening in emulator. on emulator first view loads has button titled "log point" expected previous view in stack. next view loads has "back" button - can seen on images below.

enter image description here enter image description here

this not issue on emulator , can navigate log point view. on phone app crashes when try , navigate log point view , gives error "nested push animation can result in corrupted navigation bar. finishing navigation transition in unexpected state. navigation bar subview tree might corrupted."

i have checked , not segue-ing view twice or doing not doing on first map view. know why views viewdidload method called twice? have read on error thrown list views not coming list view in case - though there list view earlier in process.

below submit point map view controller .h , .m files (some code omitted brevity)

submitpointmapviewcontroller.h

#import <uikit/uikit.h> #import <googlemaps/googlemaps.h>  @interface submitpointmapviewcontroller : uiviewcontroller <cllocationmanagerdelegate> { }  @property (nonatomic) cllocationcoordinate2d *location; @property double latitudes; @property double longitudes;  @end 

submitpointmapviewcontroller.m

#import "submitpointmapviewcontroller.h" #import <googlemaps/googlemaps.h> #import <parse/parse.h>  @interface submitpointmapviewcontroller () <gmsmapviewdelegate> @end  @implementation submitpointmapviewcontroller {     gmsmapview *mapview;     cllocationmanager *locationmanager; }  @synthesize latitudes; @synthesize longitudes;  - (void)viewdidload {     // entire method called twice - 1 right after other      mapview.delegate = self;     locationmanager = [[cllocationmanager alloc] init];      gmscameraposition *camera = [gmscameraposition camerawithlatitude: latitudes longitude: longitudes zoom:17];     mapview = [gmsmapview mapwithframe:cgrectzero camera:camera];     mapview.mylocationenabled = yes;     [mapview setmaptype:kgmstypenormal];     self.view = mapview;      // set mylocationbutton , add button mapview     mapview.settings.mylocationbutton = yes;      // setup markers on map     [self setupmarkersonmap]; } @end 

edit: below connections inspector on log point view, segue code when view on map button pushed on same view

enter image description here

- (ibaction)viewonmapbuttonpreseed:(id)sender {     [self performseguewithidentifier:@"submitpointmapviewsegue" sender:sender]; }  -(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {     if ([[segue identifier] isequaltostring:@"submitpointmapviewsegue"])     {         submitpointmapviewcontroller *vc = [segue destinationviewcontroller];         vc.latitudes = pointobject.latitude;         vc.longitudes = pointobject.longitude;     } } 

as suggested @simon goldeen , @pbasdf above - issue was pushing 2 map view controllers onto stack. there , old segue using debugging causing issue. deleted segues map view , instead segued map view follows:

submitpointmapviewcontroller *vc = [[submitpointmapviewcontroller alloc] init]; uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; vc = (submitpointmapviewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"submitpointmapviewcontrollerstoryboardid"]; [[self navigationcontroller] pushviewcontroller:vc animated:yes]; 

thought post answer here in case else had same issue.

all credit @simon goldeen , @pbasdf helping me troubleshoot issue.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -