xcode - iOS mapview auto layout issue -


im creating tab bar app storyboard.

basically on secondviewcontroller, set mkmapview toolbar @ top changing views etc.

i set span , added annotation shows when screen loaded, shows correctly when using autolayout:off shown below

(sorry couldnt embed links im new here)

http://img211.imageshack.us/img211/9359/mvautooff1.jpg

when put autolayout on this

http://img153.imageshack.us/img153/3736/mvautoon.jpg

i have tried changing span etc , nothing changes when running simulator.

how can change mapview shows when autolayout off?

can please me autolayout on resizes devices etc need mapview show how when autolayout off.

i new ios coding , totally newb

any appreciated!

thanks

the code .m -

#import "secondviewcontroller.h" #import "annotation.h"  @interface secondviewcontroller ()  @end  //coordinates of salon #define salon_latitude -33.427528; #define salon_longitude 151.341697;  //span #define the_span 0.005f;  @implementation secondviewcontroller @synthesize mymapview;  //find location button -(ibaction)findmylocation:(id)sender {  mymapview.showsuserlocation = yes; mymapview.delegate = self; [mymapview setusertrackingmode:mkusertrackingmodefollow animated:yes]; }  //set map type button -(ibaction)setmaptype:(id)sender {  switch (((uisegmentedcontrol *)sender).selectedsegmentindex) {      case 0:         mymapview.maptype = mkmaptypestandard;         break;     case 1:         mymapview.maptype = mkmaptypehybrid;         break;     case 2:         mymapview.maptype = mkmaptypesatellite;         break;      default:         mymapview.maptype = mkmaptypestandard;         break;   } }  - (void)viewdidload { [super viewdidload];  //create region mkcoordinateregion myregion;  //center cllocationcoordinate2d center; center.latitude = salon_latitude; center.longitude = salon_longitude;  //span mkcoordinatespan span; span.latitudedelta = the_span; span.longitudedelta = the_span;  myregion.center = center; myregion.span = span;  //set our mapview [mymapview setregion:myregion animated:yes];   //annotation  //1. create coordinate use annotation cllocationcoordinate2d salonlocation; salonlocation.latitude = salon_latitude; salonlocation.longitude = salon_longitude;   annotation * myannotation = [annotation alloc]; myannotation.coordinate = salonlocation; myannotation.title = @"generic haircuts"; myannotation.subtitle = @"8888 mann st, gosford, 2250";  [self.mymapview addannotation:myannotation];  //automatic annotation - custom code [self.mymapview selectannotation:myannotation animated:yes];  } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. }  @end 

try call setregion method in viewdidappear , remove viewdidload:

- (void)viewdidappear:(bool)animated {     [super viewdidappear:animated];      //create region     mkcoordinateregion myregion;      //center     cllocationcoordinate2d center;     center.latitude = salon_latitude;     center.longitude = salon_longitude;      //span     mkcoordinatespan span;     span.latitudedelta = the_span;     span.longitudedelta = the_span;      myregion.center = center;     myregion.span = span;      //set our mapview     [self.mymapview setregion:myregion animated:yes]; } 

basically auto layout, frame of map view not set yet in viewdidload:

ios autolayout - frame size width

hence setregion can not work properly.

mkmapview : setregion doesn't work !


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -