rock711 rock711 - 1 year ago 139
Objective-C Question

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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download