swift: slide in certain area to segue - view

I want to have a certain area of my mainViewContoller (mid of screen) where you can swipe left to go to another view. So I want it to work like a page view controller, but only in a certain area of the screen. How can I do this?

add a container view in your mainViewController
embed any view controller's view as container view's root view. If you want it to be a page view, set a page view controller's view as the root view.

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 add an existing view to a UIScrollView

I have created a view and the content is larger than the screen. How do I add this view as a subview of a scrollview? For some reason I can't do this in Document Outline. It will only let me add the scrollview as a subview of the existing view.
Select your view in Interfacebuilder and then use the menu command Editor:Embed In:Scroll View

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".

Tabbed view with 3rd view?

I have a tabbed app with two tabs and associated views (two views). One view is a tableview. When a cell is clicked, I'd like to display another view, which will be related to the cell contents.
This introduces a 3rd view that isn't accessed via the tabs. How do I bring in the 3rd view?
I'm guessing drop another viewcontroller onto the story board? But from there, how do I push the 3rd view into visibility upon tableview cell click?
Instead of having one UITabBarController connected to two UIViewControllers, connect your UITabBarController to a UINavigationController and a UIViewController. Put your UITableView inside the UINavigationController as root view controller. When a user taps on a cell, just perform a segue to yet another UIViewController that you push onto the navigation controller's stack.
Something like this:

Resources