ios - Map head nowhere on first time -


i put map ios app , setted in way:

- (void)viewdidload {     [super viewdidload];      cllocationcoordinate2d cord = {.latitude = 44.508473, .longitude =  11.375828};      [self.mymap setregion:mkcoordinateregionmake(cord, mkcoordinatespanmake(.005, .005)) animated:yes];       addressannotation * annotazione = [[addressannotation alloc] init];      [annotazione setcoordinate:cord];     [self.mymap addannotation:annotazione]; } 

and addressannotation.m:

- (void)setcoordinate:(cllocationcoordinate2d)coord {     coordinate = coord; } 

it works first time open map's view shows zone near antartica sea (pin head coordinates map shows antartic sea zones) , closing , reopening map's view shows pin.

how can show map zoomed on pin @ first opening?

thank much!

there's nothing wrong code. define coordinate property addressannotation , let compiler synthesize appropriate setter , rid of custom setter, though that's unrelated problem describe ... it's easier way, ensures annotation's coordinate conform kvo, etc.

i might suggest define view controller delegate of map view , implement regiondidchangeanimated:

- (void)mapview:(mkmapview *)mapview regiondidchangeanimated:(bool)animated {     nslog(@"%s %f, %f %d", __function__, mapview.region.center.latitude, mapview.region.center.longitude, animated); } 

it might useful know region getting set , maybe can reverse engineer what's going on.

but, bottom line, problem unrelated code included in question , issue undoubtedly rests elsewhere.


by doing in project, saw following log:

 2013-03-30 23:11:12.326 ibo[25408:c07] -[poimapcontroller mapview:regiondidchangeanimated:] -47.422141, 0.000000 0 2013-03-30 23:11:12.328 ibo[25408:c07] -[poimapcontroller mapview:regiondidchangeanimated:] 44.508473, 11.375828 0 2013-03-30 23:11:12.328 ibo[25408:c07] -[poimapcontroller mapview:regiondidchangeanimated:] -47.422141, 0.000000 0 2013-03-30 23:11:12.329 ibo[25408:c07] -[poimapcontroller mapview:regiondidchangeanimated:] -47.422141, 0.000000 0 

so, setting region taking place, there's else resetting region after happens. doing little playing around, discovered behavior manifests when using auto layout. if turn off auto layout, behavior goes away , works you'd expect.

alternatively, noticed if moved code set region out of viewdidload (which quite in view creation process (after view created, before appear), , put in viewdidappear, works.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -