Enable scrolling for NSTableView - cocoa

I've added a NSTableView in a NSScrollView IB in Xcode 4. Its controller class is displaying data whose horizontal length exceeds its row width. However, no horizontal scroll bars appear, so do we have to enable them?
(the table only has one column with no headers)

The data width is not the determining factor if horizontal scrolling will be enabled. You need to ensure the NSTableColumn is wider that the NSTableView for horizontal scrolling to be enabled.

Related

How do I make NSScrollView size its document view for the total size of its contents using constraints?

Say I have a Mac app with a window containing an NSScrollView. When added to a storyboard or nib file, the scroll view contains a clip view (NSClipView) and an NSView that is the scroll view's document view.
I want to add some content to this document view (say, two labels arranged vertically) and set up constraints such that the scroll view will scroll as it needs to in order to reveal all the content. So:
Pin the top, leading, and trailing of the upper label to those if its superview (the document view)
Pin the top of the lower label to the bottom of the upper label
Pin the leading, trailing, and bottom of the lower label to those of its superview (the document view)
Add a custom view to the document view, pin its bottom, left, and right edges to superview, and constrain its width to a constant (the width of the window) and its height to 0 to define the scroll view's scrollable content width
At this point, if I set the text of the labels to something long enough to overrun the height of the window, I'd expect the scroll view to allow the user to scroll to reveal the rest of the content. But it doesn't - it just elastic-scrolls vertically, and the text is cut off. Even if I set the content compression resistance to 1000 on both of the labels.
What am I missing here?
Sample app here: https://github.com/tomhamming/MacScrollTester

How to fix scrollable content size ambiguity in xcode 11 using auto layout beta 7 UIKIT

When using Auto Layout, I am unable to set up a simple UIScrollView in my view controller in Xcode 11 beta 7. I know that I must constrain the scroll view to the edges, and then set the scroll view width and height equal to the width and height of the entire view that contains the scroll view. However, I am not getting the option to set equal widths and heights when I attempt to do so.
When I do the right-click-drag from the scroll view to the entire main view, I get the following options:
Leading Space to Safe Area
Top Space to Safe Area
Trailing Space to Safe Area
Bottom Space to Safe Area
Center Horizontally in Safe Area
Center Vertically in Safe Area
In other videos, there is an "Equal Widths" and "Equal Heights" option that I don't seem to have.
Am I doing something wrong, or did Apple change the way scroll views work in Xcode 11?
I'm using beta 7 currently
I was finally able to successfully add a UIScrollView using storyboards in Xcode Version 11.0 (11A420a) after much trial and error.
You can add the scroll view directly to the root UIView of the VC or, if you needed to, add it to another UIView under the root view as needed by your UI Design. Constrain the UIScrollView parents normally for whatever your needs are.
Here is the key : when you add the UIScrollView to the storyboard, click on the Size Inspector with the UIScrollView selected. You have to UNCHECK the box that says "Content Layout Guides".
If you do this you can set the scroll view's contraints normally (I did 0-0-0-0 to superview). Then I added a UIView to the scrollview and set it's constraints to 0-0-0-0 and a height of 900 (which is what I wanted).
This will give you constraint errors in red when you set them. They will be fixed by setting the width of the UIView equal to the width of the UIScrollView.
Set the UIView width equal to the width of the UIScrollView view by Ctrl-right clicking on the UIView, dragging to the UIScrollView, and selecting the "Equal Widths" option. This should get rid of your constraint errors.
You actually can then go back to the UISCrollView Size Inspector and check the "Content Layout Guides" checkbox, no constraint errors will appear.
Disable the content layout guides in scrollview properties.
Hope it helps.. :)

10.11 NSCollectionView - automatically resize so that no scrolling is required

I'm using a NSCollectionView with OS X 10.11's Flow layout to display a varying amount of content.
If there are too many items displayed, the default is to show scroll bars according to the Scroll Direction property.
In my case, I would like to resize the height of the NSCollectionView dynamically, so that it grows larger and larger with more items being inserted.
If I simply drag the collection view out of the "Bordered Scroll View" and "Clip View", no contents are displayed at all. It's also not possible to set an AutoLayout constraint to link the height of the Bordered Scroll View to the height of the NSCollectionView. So, there has to be a different solution for this.

Autolayout Resize UImageView and UILabel when UIImageView empty

When UIImageView is empty...than resize the UILabel and hidden the UIImageView.
Anyone a idea?
You can either change label bottom constraint constant to either bottom spacing or image view top constraint - depending of visibility of image view or
(Available in iOS 8.0 and later.)
Create two bottom NSLayoutConstraint for label. One with lower priority to bottom of the view and one with higher priority. Change active property to YES/NO of the one with higher priority depending of image view visibility

trouble in scrolling in uitableview

I've created a Tableview populated with cells with a fixed tableView.rowHeight = 95.0
The problem is that when I add more cells and I try to scroll to the bottom, I can see only half cell at the bottom. I mean, when I try to scroll I can't scroll down so that to see the entire last cell added.
Seems the scrolling bar doesn't work well. Is this a bug of Xcode or did I make something wrong?
I don't want a resizable height cell but I want my cell fixed with with 95.0 but at the same time I want my scrollbar to work better.
The problem is if the table height exceeds the your mainview. At that time srollview of tableview also goes down.solution is keep the tableview height within the bounds of mainview(i.e your viewcontroller's view)

Resources