NSScrollView does not scroll

814 views Asked by At

I am attempting to implement an NSScollview for a Mac app. I have created a simple test app. In the IB, I just create a view controller with its view set to an NSScrollview.

In the viewDidLoad, I have just this code:

- (void)viewDidLoad {
    [super viewDidLoad];

    NSImage * image = [NSImage imageNamed:@"harley-davidson-electra-glide-6"];

    NSImageView *imageView = [[NSImageView alloc]initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
    imageView.image = image;

    [self.scrollView setDocumentView:imageView];
}

Note that the image size is: (width = 1920, height = 1200)

When I run this I get a window which shows just a small portion of the image. For a half-second, a horizontal scrollbar appears, then disappears; however, there is no scrolling capability. I can click and drag anywhere in the window and nothing happens.

1

There are 1 answers