How to place items in a NSScrollView - objective-c

When I try to place objects using the Interface Builder in Xcode into a NSScrollView, they appear fine until runtime in the application, where they do not appear at all for some reason. I want it to be so that I can place multiple buttons and labels in the view, and have the user be able to scroll down to see more.
Am I not meant to use NSScrollView for this purpose?
Is there another way to go about implementing it I am not aware of?

You need to check the where you added the UI objects.
You need to consider these :
Is your autolayout enabled?
Did you flipped the view?
Resizing mask is working good as per your requirement.
Am I not meant to use NSScrollView for this purpose?
No, you picked the correct control for the requirement. NSScrollView is indeed for same kind of use.

Related

How to disable accessibility support for the divider of a NSSplitView?

I have a NSSplitView in my app. Its divider position is fixed, the user is not able to drag the divider around. Now I am adding support for accessibility. When using VoiceOver, the user can select & drag the divider. That breaks my UI.
How can I tell VoiceOver, that it should ignore the divider?
I am using the new Accessibility Protocol available since OS X 10.10.
Setting splitView.isAccessibilityElement or splitView.isAccessibilityEnabled to no does not work.
Thanks for your help!
Ok, I asked a nice guy from the AppKit team at WWDC.
He told me that this is not possible at the moment - because I can not acces the divider within the splitView.
Explanation:
Disabling the accessibility support on a NSView, makes the particular view inaccessible, but not its sub view - which is the desired behavior normally
Since the divider is a subview of NSSplitView, this does not work.
Solution:
I ended up not using NSSplitView anymore because I don't need any of the class specific features. The dividers are fixed in my application.
Instead I used NSStackView to encapsulate my subviews - and it works perfectly. (Hide and show subviews)

Is there a tutorial somewhere about designing a really large view and put it in scrollView using storyboard

The question may be similar with
Designing inside a scrollview in xcode 4.2 with storyboards
but none of the answer there makes sense at all.
Okay I created a new controller and I added a scrollView.
The very first thing I noticed is there is NOWHERE to specify the content size of the scrollView.
Not in attributes inspector, not in size inspector.
Then what?
I am expecting some larger than normal box where I can draw all the view I want to put in. There is no such thing either.
I am very frustated.
All the "tutorial" out there tell about how to fill scrollView using code.
Another thing I tried is to select controller go to size inspector and then choose FREEFORM.
Great. I still can't make that template big.
Should I do this in XIB instead? At least on that one I can have one huge UIView. Or what is the official way industry standard way of doing this? Is there a WWDC for this one?
Say I want to draw something like these:
I don't think you can get a tutorial on this as it is simply impossible in IB. As most people already commented out what you want to do here need to be done programmatically.
If you are using XIB you can set up all your content there. Under the size tab (in the inspector) you will need to change the height to fill all your content but you still need to set up your contentSize programmatically.
For storyboard I don't think it is possible to change the size of your scrollview in IB.

Programmatically added UI items order next to each other

There is a UIScrollView and I'd like to programmatically put subviews in it. It's ok, but how can I lay automatically the subviews next to each other?
Thanks in advance!
You can't. The view hierarchy in UIKit--like the view hierarchy in most UI frameworks--uses explicit layout.
Your comment asks about HTML-like floating; the box model stuff that HTML/CSS uses was designed to serve a very different goal (flowing document layout) than what UIKit is for, and so there's no real analogy in the framework.
UIViews do support automatic re-layout on resize/frame change of the parent view (you can say whether a subview should resize, how, and where it should be "pinned" to), through the autoresizing mask property, but I don't think that's what you're asking for.
You could, if you were inclined, build a set of methods, perhaps as a category on UIView, that let you add subviews that had their frame origins adjusted automatically based on existing subviews.
The position of the subviews is dictated by their frame property. So you need to set their frames such that they line up next to each other.
If they are all the same size you can do with some simple math and CGRectMake(). If they will have different sizes, you can use CGRectDivide() to break a large rect into smaller rects. CGRectInset() is also useful, in case you want some padding between them.

Create Vertical-Tabbed OS X Cocoa View

I'm interested in having a application with a layout similar to the tabbed operation of iChat (see image below).
Does anyone know of any pre-built constructs that allow this sort of UI? I know there is NSTabView for tabs across the top of the application, but what about vertical orientation? For my purposes, the view associated with the tabs doesn't necessarily need to scroll. In fact it has nothing to do with chatting anyway, I simply like this layout.
Thanks.
The view on the left is an NSTableView with source list-style highlighting:
tableView.selectionHighlightStyle = NSTableViewSelectionHighlightStyleSourceList;
You can use a tabless NSTabView for the right part, but you could just as well change the content of the displayed views or swap the views entirely. That depends on how many “tabs” there’ll be and how the content displayed on the right side will be different.

IKImageView and scroll bars

I have an NSScrollView with an IKImageView inside to display images. This seems to work.
However, if I make the window smaller than the image, the scrollbars appear as they should, but the BOTTOM of the image is locked to the bottom of the window, instead of the top of the image being locked to the top of the window. In other words, I want the image to not move on the screen when I re-size the window from the bottom right.
I understand why this is, because in All of these classes, the origin is in the lower left, not the upper left. However, It's still behaving wrong. If you look at any other product (including Preview, which I assume is written with some of these libraries) the image/content/whatever, is locked to the top not the bottom.
How do I do this?
I've looked for methods in the NSScrollView and IKImageView. I've considered capturing the scroller events and manually moving the image down or up as appropriate, but I haven't seen a way to do this (Set the selector to a method I write in the controller?) and anyway, that seems very messy...
Is there an easy way to do this?
thanks.
Solution for future reference:
Make a subclass of IKImageView with only one over-ridden method:
-isFlipped()
{
return YES;
}
This subclass will also prove useful if I find that I need to re-implement the rotate:(id) method and the setImage:(NSImage) method which exist in the class (and in the case of rotate are USED IN THE DEMO supplied by Apple) but not documented, and therefore not officially supported...