Re: When I rotate the MKMapView with transform, setCenter not working.

2014-10-31 Thread sonofsky2...@gmail.com
Hi, 
I have solved this problem.
Do not change the frame of map view when it’s transform does not equal to 
CGAffineTransformIdentity.


Best Regards,
Sunny Lee




 在 2014年10月31日,上午12:54,sonofsky2...@gmail.com 写道:
 
 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: When I rotate the MKMapView with transform, setCenter not working.

2014-10-31 Thread Mike Abdullah

 On 31 Oct 2014, at 11:43, sonofsky2...@gmail.com wrote:
 
 Hi, 
 I have solved this problem.
 Do not change the frame of map view when it’s transform does not equal to 
 CGAffineTransformIdentity.

This is a general rule about UIView. Once the transform is anything other than 
identity, .frame becomes undefined and should be left alone.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

When I rotate the MKMapView with transform, setCenter not working.

2014-10-30 Thread sonofsky2...@gmail.com
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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com