ios - Apple Mapkit: Map doesn't start with my given coordinates -
i'm trying open map given set of co ordinates. isn't working. works if exit view , enter again.
here code -
mapviewcontroller.h
#import <uikit/uikit.h> #import <mapkit/mapkit.h> @interface mapviewcontroller : uiviewcontroller <mkmapviewdelegate> @property (strong, nonatomic) iboutlet mkmapview *mapview; @end
mapviewcontroller.m
#import "mapviewcontroller.h" @interface mapviewcontroller () @end @implementation mapviewcontroller @synthesize mapview; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; self.mapview.delegate = self; cllocationcoordinate2d zoomlocation; zoomlocation.latitude = 39.281516; zoomlocation.longitude= -76.580806; mkcoordinateregion region = mkcoordinateregionmakewithdistance(zoomlocation, 800, 800); [self.mapview setregion:[self.mapview regionthatfits:region] animated:yes]; } @end
sometimes have found methods animate screen not work expected when running @ same time view controller transitions. try moving code zoom map viewdidappear
.
Comments
Post a Comment