NSScrollView coordinate system

btoth

Person that uses a Mac
Currently I have an NSImageView as a subview of a NSScrollView in my window. What I would like is instead of the ImageView being positioned at the bottom-left of the ScrollView's ContentView, I want it positioned in the top-left corner.

Should this be as easy as subclassing NSScrollView and overriding it's isFlipped: method? Or is there some other, more complex task that needs to be done. I've tried just reposition the ImageView frame offset from the bottom, but no matter what I make it's Rect.Origin set to, it doesn't change it's position.

Maybe I've missed something obvious? I find this frustrating seeing as how my program works fine otherwise: toolbars, draws, multi-threading, etc... but I can't figure out how to reposition the ImageView. :)

Any help would be appreciated.

Relevant header vars in MyWindowController.h, a subclass of NSWindowController that is the owner and delegate of my NSWindow:

Code:
IBOutlet NSImageView * imageView;
IBOutlet NSScrollView * scrollView;

/* [super window] points to the NSWindow */
 

Attachments

  • noscroll.jpg
    noscroll.jpg
    34.2 KB · Views: 4
  • scroll.jpg
    scroll.jpg
    27.8 KB · Views: 4
I figured it out. All I needed was a golf break. I made a subclass of NSImageView call FlippedImageView and made it the custom class of my image view and overrided one method to flip the coordinates:

Code:
- (BOOL)isFlipped
{
    return YES;
}

Back on track again.
 
Back
Top