Friday, April 29, 2011

How do you flip the coordinate system of an NSView?

I have created an NSScrollView in interface builder that has a variable number of semi-unique NSViews that can be programmatically added and removed from it. When I add subViews to the documentView, they appear in the lower-left hand corner instead of the upper-left hand corner. I see that you can check the isFlipped bool to figure out if the view's coordinate system is flipped, but I cannot find a way to set it as flipped.

Anyone know what I'm missing?

From stackoverflow
  • In your NSView subclass, override the isFlipped method:

    isFlipped Returns YES if the receiver uses flipped drawing coordinates or NO if it uses native coordinates.

    - (BOOL)isFlipped

    Discussion The default implementation returns NO; subclasses that use flipped coordinates should override this method to return YES.

0 comments:

Post a Comment