objective-cxcodemacosxcode5nsaffinetransform

Does NSAffineTransform have different Coordinate system in Mac OS X 10.11?


My project works well on Mac OSX 10.10/10.9, however it works incorrectly in 10.11 with this code:

[(PDFAnnotationInk*)_activeAnnotation removeBezierPath:_path];

[_activeAnnotation setBounds:bound];                           

// Lazy, redraw entire view.        

 NSAffineTransform* transform = [NSAffineTransform transform]; 

[transform translateXBy:-bound.origin.x yBy:-bound.origin.y];

 [_path transformUsingAffineTransform:transform];

[(PDFAnnotationInk*)_activeAnnotation addBezierPath:_path]; 

[[_activeAnnotation page] removeAnnotation: _activeAnnotation];     

[self addAnnotationSelector:_activeAnnotation];

When I change this [transform translateXBy:-bound.origin.x yBy:-bound.origin.y];

to

[transform translateXBy:bound.origin.x yBy:bound.origin.y];

The application works correctly on OSX 10.11, but incorrectly on OSX 10.10/10.9...

I don't know why, Does NSAffineTransform have different Coordinate system in latest Mac OS X 10.11? How can I solve this to make the application compatible with both 10.10/9 and 10.11? Thanks.


Solution

  • I had the same problem. The rules for how to position annotations are not documented; nowhere does it say that ink paths have to be relative to the origin of the annotation, but they do. I assume that someone at Apple either broke it accidentally or changed their minds about how it should work.

    Until they change their minds again (or fix the bug), I am checking the system version (using the ProductVersion key in /System/Library/CoreServices/SystemVersion.plist) and doing it the old way for 10.10 and earlier, and the new way with non-inverted origin for 10.11 and later.