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

  • SEARCH
  • Home
  • 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 8023749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:39:14+00:00 2026-06-04T22:39:14+00:00

Is there a simple way to get an NSScrollView to adapt to its document

  • 0

Is there a simple way to get an NSScrollView to adapt to its document view changing size when using auto layout?

I have tried to call both setNeedsUpdateConstraints: and setNeedsLayout: on the document view, the clip view and the scroll view, without any results.

fittingSize of the document view reports the correct size.

The problem is that the document view, which holds subviews, is not re-sized when the subviews change their size, even if they call invalidateIntrinsicContentSize. The contents of the document view are hence clipped to the original size of the document view as they grow. The document view is created in a nib and set as the scroll view’s document view in an awakeFromBib method.

I was hoping that the document view frame would automatically be adjusted when its fittingSize changes, and the scrollbars updated accordingly.

NSPopover does something similar – provided that the subviews of the content controller’s view have the constraints set right and various content hugging values are high enough (higher than the hidden popover window’s hight constraint priority, for one).

  • 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-06-04T22:39:16+00:00Added an answer on June 4, 2026 at 10:39 pm

    The problem of course is that when adding the document view, Cocoa will automatically create some hard constraints in the view that the document view is inserted into, i.e., the clip view.

    So the answer to my own question is simple, just use:

    // Assume self.docView is an IBOutlet populated with
    // an NSView subclass
    self.docView.translatesAutoresizingMaskIntoConstraints = NO;
    

    before you add the document view to the scroll view:

    self.scrollView.documentView = self.docView;
    

    Now, since there are no auto-generated constraints on the layout of the document view in the clip view, you will need to add them explicitly. Otherwise, the doc view’s contents will just be rendered at their intrinsic size in the upper left corner of the scroll view.

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

Sidebar

Related Questions

Is there a simple way to get the application name using Boost (maybe with
Is there a simple way to get a system's uptime using C#?
Is there any (simple) way to get some control of the order in which
Is there a simple way to get array of all index paths for the
is there a more simple way to get combobox (WinForms) selected items text? string
Is there a simple way to add and change interpreters using the Pydev plugin
Is there a simple way to get the PropertyInfo for a property in a
Is there a simple way to get the parameters at the end of an
is there a simple way to get the number of the current item in
Is there a simple way to get the total of all items in a

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.