Split view divider is not showing up when subclassing from NSSplitView - macos

I created a custom SplitView class that subclasses from NSSplitView. Everything looks right to me, and works fine, except the divider. For some reason it doesn't want to show up between my views of a SplitView.
Any kind of hint or help is highly appreciated!
here is my setup in the nib:
and here how it looks when I run it
interesting thing is, that when I move the mouse to the place where the divider should be, the cursor changes and I'm able to drag it...but for some reason it doesn't look right

You can change the color of the divider using the 'drawDividerInRect:' function to change the color of the divider by passing your own rectangle. It is also possible you moved one of the custom views in the split view and can't see the divider anymore. You could try selecting the different views using the object hierarchy.
I've found that apple doesn't like to make it easy to modify a lot of their different views and controllers, probably because they are trying to maintain some uniformity in the apps that are run on their system.
Is the hidden check box checked?

Related

Split View Controller showing only one view (Xcode 6)

I'm trying to get the split view controller working properly but apparently there's a bug in there or I'm missing something.
First of all, I've started a blank OSX Obj-C application, and in the Storyboard I've dragged the split view controller. Next, I've linked the segues from the main window controller to the split view and added two labels.
http://i.imgur.com/dlFObaF.png
When I build the project, it shows only the second page. Not to mention strange window size in the final build.
http://i.stack.imgur.com/IqRqr.png
I've tried everything.
This occurs in both vertical and horizontal split view.
Any suggestions?
I had the same issue myself today, but it's just the split line wasn't initiated properly.
To see, this, once you run your app, move your mouse toward the edge of the window and drag it, you will now see another view emerging.
To my best knowledge, I do not know how to fix this in IB or in code. Apparently NSSplitViewController does not have a property like UISplitViewControllerAutomaticDimension. Would appreciate if someone can contribute to this.
Edited: Found an answer via another thread. Basically, try to add some constraints to the subviews inside each view and that should prevent the size of a view to be zero. In my toy example, adding margin constraints to my buttons worked out well.

IOS/Xcode: storyboard screen turning black

I am just learning Xcode. I did something that caused a view controller to turn black below the navigation bar when you build app.
It looks white in storyboard.
Also, when I pull a label onto the storyboard, it aligns to the left margin and does not show the drag boxes around it.
I may have inadvertently clicked something but when I compared it in attributes and identity inspectors line by line to another project, nothing seems amiss, i.e. everything is the default value.
Has anyone run across this?
There is not code in associated class that would cause this as it is generic i.e. plain vanilla.
Would appreciate any suggestions. Thx.
With that little information i'd say you removed the root view of the controller?
Either way, you say there is no code, so I'd suggest you simply delete that controller and create another one (bottom right, objects, viewcontroller). Since it's empty you're not gonna lose any data or time :)
Then link it to your class in the Identity Inspector and you're good to go as if it was a new one.

How can i split a nswindow?

So I am trying to emulate the new cleanlymac app. It looks like it has two windows on top of each other, one without the traffic lights and the other with it, but they were treated as one. That had the ability for the back one to slip out at the beginning. Would anyone have a good idea of how this was constructed?
Here is a photo of the cleanmymac app:
They are actually ONE WINDOW.
You can easily acheive this by using vertical NSSplitView with 2 panes.
Here you can opt for divider in between or fix the splitter.
And in each of the splitViews a new NSView is placed. Here in this view you can put your views from a single or multiple xibs.
Check here for ViewOnWindow how you can show a view from another xib to your main window.
Check here for tutorial.
That looks like a custom window with the black background for the top right part of the window. Search for custom window cocoa to find examples of how to do this. I don't see the point of the custom window in this situation, you could just split the content of the window, it probable branding.

Programmatically create UI or drag and drop in storyboard for iOS development

First time building a user interface, had a few general questions
1) Does it really matter if you drag and drop view objects into view controller.. or if you programmatically add subviews and specify frames and fonts? What's the better approach to take?
2) In the programmatic approach, I end up guessing frame values, (x,y) points, and then checking in simulator if I like it. Is this the right approach, or are there faster, better ways to build out the UI? Maybe methods I'm not aware of?
3) Any useful tutorials/pointers in the right direction on how to get started?
Thanks!
1) Both approaches are fine, but the Interface Builder is usually better if you have a more static UI. In a more dynamic app (where views appear and disappear, or if you use UIViewController containment), you need to add/show/hide some of the views in the code. Even in that case you can design individual views in the IB, to make sure they look good, and then instantiate and display them in the code.
2) If you design your views in the IB, then the problem of guessing the sizes largely disappears. In some cases it can be useful to have an empty view added in the IB, which acts as a placeholder for your dynamic content. Then, when you add a view to it in the code, you just use the superview's dimensions so your view fills the placeholder.

How to imitate the workflow view of Automator?

I’m starting to develop my first full-blown Cocoa application containing a view which I would like to behave (and look) similar to Automator’s AMWorkflowView.
The basic features I’d like to achieve:
Positioning of subviews
Display of subviews in expanded / collapsed states
Multiple selection
Drag and drop
In order to get accustomed to Cocoa, I started with a custom NSView which mainly served as a container for the custom subviews and handled their positioning and multiple selection.
The subviews are also subclasses of NSView, and contain a variable amount of views themselves, like buttons, labels and popup menus, and therefore can have different heights.
This worked quite well, but before going on, I want to make sure to have everything neat and tidy according to the MVC pattern.
I suspect that there already is a class in Cocoa that facilitates the implementation of a view container, like maybe NSCollectionView.
It seems that there is no (easy) way to display differently sized views in an NSCollectionView, though. Should I continue implementing my custom NSView (probably using an NSArrayController for selection and sorting support), or are there better ways to go?
Any help is much appreciated
Unfortunately the answer is you'll have to roll your own. NSCollectionView does not allow for variable-sized items (which also rules out expanded/collapsed states).
For a limited number of items, you can accomplish this rather easily (you just need a container view that arranges the subviews properly when asked to layout, then you need to make sure you re-layout when things change). For many subviews, however, you'll need to take care to be as efficient as possible. This can start with laying out as little as possible (only those "after" the resized view, for example) and get as complex as caching a visual representation of a prototype view, drawing the cached images (fast!) for all but the view being edited, and only using/positioning a "real" view for the view being edited.
Drag and drop works the same as it always has, but none of the above accounts for the pretty animation NSCollectionView gives you. :-) It's fast and beautifully-animated precisely because all the subviews are uniform (so the layout calculations are fast and simple). Once you add irregular sizes, the problem becomes significantly more complicated.
The bottom line: If you need variably-sized views, NSCollectionView will not work and you'll need to roll your own or find someone else's shared code, but performance and beautiful animation will not be easy.

Resources