When I rotate the MKMapView with transform, setCenter not working.
When I rotate the MKMapView with transform, setCenter not working.
- Subject: When I rotate the MKMapView with transform, setCenter not working.
- From: "email@hidden" <email@hidden>
- Date: Fri, 31 Oct 2014 00:54:28 +0800
Hi all,
I rotate the MKMapView with setting the rotation transform. When I use setCenter method to change the center coordinate of the map, the location of this coordinate not in the center. Does anyone know what happened, and how to solve this problem? Below is the code snipt.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
static CLLocationCoordinate2D aircraftCoordinate = {22.531474, 113.943516};
CGFloat width = self.view.bounds.size.width;
CGFloat height = self.view.bounds.size.height;
CGFloat newSize = sqrt(width* width + height * height);
UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
[self.view insertSubview:tmpView atIndex:0];
self.containorView = tmpView;
MKMapView *tmpMapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, newSize, newSize)];
[self.containorView addSubview:tmpMapView];
self.mapView = tmpMapView;
[tmpMapView setCenter:self.containorView.center];
self.annotation = [[DJITestAnnotation alloc] init];
_annotation.coordinate = aircraftCoordinate;
[self.mapView addAnnotation:self.annotation];
self.mapView.delegate = self;
[self.mapView setTransform:CGAffineTransformMakeRotation(90 * M_PI_4 / 180)];
}
- (IBAction)location:(id)sender {
self.mapView.camera.centerCoordinate = _annotation.coordinate;
}
Best Regards,
Sunny Lee
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden