Make the viewController's view a NSVisualEffectsView - macos

I create a new viewController on storyboard. I want that viewController's view to shown thru the window. So, as far as I understood, I have to transform that view to a NSVisualEffects view.
How do I do that using interface builder?
I already have a lot of objects on that view added using interface builder, so, it will be nice to solve that using interface builder.
thanks

1) You can delete the view in the outline view and then add a visual effects view as the view controller's view.
2) Add a effects view as the subview of the view.
3) Change the class type of the view controller's view in the inspector window.
Options one and two will let you see the effects view in Xcode. I would recommend using option 3.

Related

macOS/ Xcode / Swift 3, how can I have a storyboard scene inside a NSScrollView?

I am new to storyboards and just learning swift. My document based app has a main document view where all the action is (user mouse clicks, keyDown, etc). It's size can vary based on either user menu command or model state changes. It also has subviews that may come and go. This needs to be the document view of an NSScrollview.
This document view needs its own view controller.
Starting with the main storyboard if I add a scroll view to the main view controller view, I can set my custom view to be the document view. But there doesn't seem to be anyway to give it it's own view controller, within the storyboard paradigm.
Previously, (under objective c, if that matters), I was able to create my document view and it's view controller in a XIB, then in code assign this document view to the NSScrollview's document view.
Presumably, I could still do this in code in Xcode 8/Swift 3, but isn't there a way to do it with storyboards?
Added Later: I seem to get close to what I want by replacing the scroll view's document view with a container view. I'm using a centering clip view, and apparently the container view cannot have constraints, or it defeats the centering!
I can then drag a new view controller onto the container view. The new view controller and it's view can be my custom view controller and it's custom view.
This looks like it will work OK, so far, but it seems a bit of a kludge to me. Is this the standard way to embed a custom view controller with its view in an NSScrollView?

How to drag a View Controller on top of a View Controller?

I have a View Controller that is presented when you first open the app, and I have another controller that can be shown on screen if you tap a button at the top of the screen. However, instead of doing it this way I was wondering if I can either drag the view down or tap the button and have an animation take care of that.
I have tried doing this with a PageView Controller, but this doesn't show the effect I wanted as it simply translates over to the next view and doesn't actually keep the initial view fixed in place while the second view slides over it.
Also, instead of a view controller would a view initially placed out of bounds in the main View Controller work? Thanks in advance!
You could use a side menu like MMDrawerController that has 4 type of animations for presenting the viewController.
Or you can create your custom UIView (not viewController) even using Interface Builder and animate that screen yourself. The animation can be started using UIScreenEdgePanGestureRecognizer.

Embedding Custom View with controls in NSScrollView

I'm trying to create a scrollable view with multiple controls inside it. For this I'm wrapping a Custom View control inside a NSScrollView and set the size of the custom view to about the same as the scroll view.
However if I place other controls inside the custom view in Interface Builder they don't appear in the custom view when running. Why is that?
If I place a button in a Custom View that is not wrapped in a NSScrollView it works but I want the custom view to be scrollable in case the window height is too small to show all controls.
After dragging in an NSScrollView in Interface Builder, look at the outline view in the xib window. You'll see that you now have a Bordered Scroll View, which contains a ClipView, which then contains a NSView.
a. Make sure your Custom View have been added as a subview to the NSView. If you add them at a higher level, you wont get the behavior you want.
or
b. Another option is to simply change the class of the NSView to your custom view class. Select the View that is inside the BorderedScrollView->ClipView, then click the 3rd tab from left (in the upper right of Xcode window) where you can type in your custom class name in the field labeled "Class".

Replace subview of NSSplitview with custom view

I still have a lot to learn with cocoa so I may have missed something obvious here. I have a custom view I would like to display in an nssplitview which replaces the current subview there.
I have a MessageView.xib file, and a MessageView .h/.m which subclasses NSView. I created a custom view instance for my main window (the one which contains the nssplitview) through Xcode 4's built in gui builder. I created an outlet to this instance of MessageView in my window's controller.
In my controller for the window when I want to swap out the subview for the splitview it runs this
[splitView replaceSubview:[[splitView subviews] objectAtIndex:1] with:viewMessage];
viewMessage is the outlet to the MessageView.
When this code is run the display of that subview changes to be blank. I'm not sure if there is something wrong with my custom view or there is some size issue. Is there something I need to do to fit the view into the split screen view or is my custom view just not displaying correctly? I have had a difficult time finding a tutorial on creating custom subviews with Xcode 4 so I'm not sure if something could be wrong with that. The custom view just has a label and a textfield in it.
Generally, you shouldn't need to replace NSSplitView's subviews with your own. Rather, you add your own custom view(s) as child views of the default subviews on each side of the divider. You can do this in code with addSubview:, but it's probably easier to just use Interface Builder in Xcode. Drag a "Custom View" into the splitview, then in the Identity Inspector, under Custom class, change the class to the name of your custom NSView subclass:
I think (off the top of my head, not tested), if you really do need to replace the default NSSplitView subviews with your own class, you can probably do it in Interface Builder using this same method, but selecting the default subview itself and changing its class in the inspector. This doesn't work for all AppKit classes, but it may work for NSSplitView.

How to set size of UITableView inside Interface Builder?

Is it possible to change the frame of UITableViewController's UITableView frame inside Interface Builder? I want to make my table, which I instantiate in IB, a little bit narrower.
When you have create your tableViewController in IB, if you then go to the section on the right of the screen where all the options are set size to "freeform" then drag it to whatever you like. When you init it it will then get this frame. Unless it is within a container controller.
The best way to do what you are after is to create a viewController and add a table view to its view. Make the table view narrower that the main controller view and wire it up to an IBOutlet on your controller. If you then make your controller implement the and methods you will be able to use your table view exactly as you want to.
Hope this is of help to you, if this is unclear or you would like any extra help, let me know :)
You can change it in IB but unless you customize your view controller somehow, it will set it be full screen (module enclosing controllers like nav, tab bar, split view, etc.) That's just the way view controllers work.
From the Apple docs:
When a view controller is displayed on screen, its root view is
typically resized to fit the available space, which can vary depending
on the window’s current orientation and the presence of other
interface elements such as the status bar.
You can create another UIView to hold your table view and then have more control over the table view sizing, But then you won't be a table view controller and will have to implement some of the things that table view controller provides you, e.g., deselectRowAtIndexPath on viewDidAppear.

Resources