Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1021263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:17:07+00:00 2026-05-16T11:17:07+00:00

Cocoa’s NSScrollView is horribly under-explained. I hope someone here knows what it’s all about

  • 0

Cocoa’s NSScrollView is horribly under-explained. I hope someone here knows what it’s all about and can spare me a few seconds.

So I have a custom NSView. I implement -drawRect: for it to draw something, fill itself with colour, whatever. Then I have an NSScrollView wrapping it (set up through the interface Builder).

Now the inner, custom, view must have a size larger than that which fits in the outer scroll view—for it to scroll. That much I realise. I have incidentally configured it so that the scroll view adjusts to the surrounding window’s size, but that shouldn’t matter.

I override my inner view’s -frame method to return a frame sized at least 1000×1000.

- (NSRect)frame {
    CGFloat w = 1000;
    CGFloat h = 1000;
    if (self.superview.bounds.size.width > w)
        w = self.superview.bounds.size.width;
    if (self.superview.bounds.size.height > h)
        h = self.superview.bounds.size.height;
    return NSMakeRect(0, 0, w, h);
}

Here’s the outcome, which I have trouble interpreting:

  • I can scroll when the scroll view encloses an area smaller than 1000×1000

BUT

  • The only area filled with colour (i.e. that my -drawRect: method has any effect on) is

    • as large as the scroll view’s bounds
    • located at (0,0. I use flipped, so that’s top left, and it ends up being outside the visible area after scrolling.
  • The visible area that lies outside this irrelevant rectangle is not painted at all.

I don’t know anything beyond this point. It seems like the rect for drawing is clipped to the scroll view’s position in the window, and size, or something—but it does not take the scrolled “location” into account.

It should be noted that I don’t really expect anything else to happen. I feel I am missing a piece, but can’t find which. Sorry for the wall of text, but I can’t explain better right now. I hope it is easier to answer than it is to ask.

Regards and hope,

Not Rick Astley

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:17:08+00:00Added an answer on May 16, 2026 at 11:17 am

    It’s a very very very bad idea to overwrite -frame. There is so much that depends on the actual instance variable having a correct value. Instead try to set the frame to the one you want using setFrame:, that might fix all your problems if you’re lucky…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Cocoa app needs some small dynamically generated windows. How can I programmatically create
In Cocoa, how can I write a string to a text file without replacing
Being new to Cocoa, and probably not knowing all of the potential classes available
I was develop some Cocoa application with WebView . Now I can evaluate javascript
In Cocoa, NSTextView has a rather shallow margin between text and border. Is there
In Cocoa, specifically the iPhone SDK, the opaque property is described as: If opaque,
NSInteger / NSUInteger are Cocoa-defined replacements for the regular built-in types. Is there any
I have a Cocoa app that uses a WebView to display an HTML interface.
I am writing a Cocoa application with Mono embedded. I want to run and
I'm a newbie Cocoa developer and I'm developing my first application. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.