• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
When I rotate the MKMapView with transform, setCenter not working.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: When I rotate the MKMapView with transform, setCenter not working.
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: NSSplitView divider tracking-area
  • Next by Date: Can an use introspection to determine if its a production app from the App Store?
  • Previous by thread: [MEET] Toronto CocoaHeads / tacow - November 12
  • Next by thread: Re: When I rotate the MKMapView with transform, setCenter not working.
  • Index(es):
    • Date
    • Thread