문제

I have got a test compass VC with the proverbial compass image (128 x 128) with central co-ords 128,160. When I rotate the iPhone the compass moves correctly BUT jumps all over the place.

I have tried inserting additional code out of paranoia to force it to stay within central bounds but doesn't appear to make any difference.

Any ideas?

EH

-(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading*)newHeading {
    if (newHeading.headingAccuracy > 0) {    
        self.currentHeading = newHeading;    
        self.trueHeadingLabel.text = [NSString stringWithFormat:@"%d", (int)newHeading.trueHeading];    
        self.magneticHeadingLabel.text = [NSString stringWithFormat:@"%d", (int)newHeading.magneticHeading];    
        float heading = -((newHeading.magneticHeading*M_PI)/180.0f);    

        // Additional code to force image starts here
        self.arrowImage.frame = CGRectMake(128,160,128,128);    
        self.arrowImage.layer.anchorPoint = CGPointMake(0.5,0.5);    
        self.arrowImage.center = CGPointMake(160,160);   
        // Additional code to force image ends here

        self.arrowImage.transform = CGAffineTransformMakeRotation(heading);
    }
}
도움이 되었습니까?

해결책 2

SORTED but this makes no sense. No anchor points, no layers used. All I did in the Size Inspector was change the width/height of the image to 1,1 rather than the true size of the image which is 128,128.

다른 팁

have you tried setting the anchor point of the view to it's center? this should result in rotating around the center and not around (0,0). you can try some code like:

[self layer].anchorPoint = CGPointMake(width/2, height/2);

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top