How to SceneKit do not on the whole screen - ios

As in a conventional project Single View add Scene Kit View on View controller, size 250x250. I need create Onboarding page.
In project i add Page View Controller and root View Controller and Content View Controller. I think add Scene Kit View on Content View Controller. I have problem assigning class SCNView on Scene Kit. As far as I know it should be to fill the screen, but I need to do it only for animation pictures.
Thanks for any suggestions! I'm very excited to hear your suggestions.

You can constrain your SKView just like any other view so that it only fills the part of the display that you need.
For example, if using storyboards:
Create a viewController as normal,
Drag and drop a new view onto this controller (Xcode 7 does not have a SKView in the object library, so use a normal view).
Size this view and add constraints to it to put it where you need it on the display.
Select this view and change its 'Custom Class' to be an SKView.
Link this new SKView to an outlet in your code.
Use this outlet to present your SKScene into the SKView.

Related

How do I make a view that stays onscreen when the main view segues?

How do I make a view that does not appear to be reloaded (stays onscreen) every time a view segues? Like the audio controls in Apple's iOS podcast app. See pictures to see audio controls I am referencing.
How do I do it in storyboard?
What you are referring to is usually called "mini player", you'll find it in many other apps too.
The technique you should use is called "UIViewController Containment", in storyboards it is accessible as "Container View" and "Embed Segues".
A typical storyboard might look like:
The root view controller has two Container View added to it's view.
The container views have segues to view controllers. In the view
controller that relates to the lower one, setup the mini player.
The view controller of the upper container embed in a navigation
controller and a tab view controller.
This will create the view controller hierarchy.
To implement the player itself create a player class that you instantiate in the app delegate and pass it to a property on the root vc. from there pass it to the mini player view controller and to the upper view controller, that will contain the list of songs/podcast/... to select from. At selection pass hat song to the player class.
I posted an example app at GitHub: https://github.com/vikingosegundo/HearThisMiniplayer
I think you can do it adding it on top of application window(which is UIWindow, subclass of UIView)
UIView *myView = /* <- Your custom view */;
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
[currentWindow addSubview:myView];
Took the code from https://stackoverflow.com/a/21850538/1947419
Or you can add to UITabBarController.view directly since it's UIView spanning entire screen.
You need to make custom view for it though.

iOS Storyboard: Views outside of the ViewController and on Top of the Scene (between First Responder and Exit boxes)

I am having a hard time understanding why you can put UIViews outside the UIViewController on the storyboard, and what the use case of it might be.
For instance, on the storyboard I can add UIToolbar, UIAcitivtyIndicator and UIProgressView that is outside of the UIViewController. Is this mean there is a way for you to reference those Views that are outside UIViewController and potentially display them somehow either programmatically or embed those like you would do with a ContainerView?
Yes, it absolutely is possible to do what you're describing!
When you add objects that are outside the view controller, they appear in what Apple calls the "Scene Dock". Apple has the following suggested usage for the scene dock:
If a view is not part of the main view hierarchy — such as a pop-up
menu — add the view to the scene dock. In a running app, the system adds
and removes these kind of views from the view hierarchy when they are
opened and closed.
The steps to make this work are below:
Open the storyboard.
Open the utilities area for the workspace window by clicking the
utilities button in the
toolbar.
In the utilities area, select the Object library by clicking the Object Library button in the library bar.
On the storyboard, select the scene to which you will add the extra view.
Drag a view class object from the object library into the the scene dock.
And importantly...
The added view is a part of the view controller. It will be
instantiated along with the rest of the views. You can attach the view
to a property of the view controller that has an IBOutlet. You can add
more than one view to the scene dock.
(These steps were originally copied from here - unfortunately this page seems to have been deleted by Apple at some point).

Swift: how to implement additional view controllers with sprite kit game?

Ok, so I'm a beginner here and I am creating a game with Swift in sprite kit.
So far in my storyboard I have the initial View Controller and the Game scene.
I know that my game scene is implemented via the GameScene.swift file, i.e whatever code I write in GameScene.swift affects and correlates to the Game scene.
This is all fine, However I do not understand where I can write code that alters the initial view controller.
I would have assumed that the view controller would be affected by code written in the GameViewController.swift file, however when I try to connect labels and image views from my storyboard to GameViewController.swift by pressing control and dragging, nothing connects. Thus, I have no way of implementing the initial view controller.
Similarly, I cannot implement any additional view controllers that I create in my storyboard.
I can put labels and image views and everything into my view controllers, but I can't connect them to any file to make them do anything.
How do I do this?
It sounds like you have 2 different screens in the storyboard. Each view in a storyboard needs a separate view controller. To connect the ViewController.swift, you need to select the view in the storyboard, and in the identity inspector, make the class the viewController.

How to show flow in storyboard in the following scenario

I need to show UIVIew when i will swipeup on UIViewController in ios with animation like it is coming from that UIVIewController,and i need to place that UIVIew in specific portion in UIVIewController not to cover on entire area.But my problem is i need to create this one in storyboard,normally storyboard means its for showing over all project flow so ,how to do that in storyboard.Please help me as soon as possible.I am new to iphone development i can do by programatically but i am not getting how to do with xib.
Thanks & Regards
Harshitha
You're going to want to look at custom View Controller transitions, introduced in iOS 7. There were a couple of WWDC 2013 sessions on this, including one called "Implementing Engaging UI"
The fact that you're using a storyboard doesn't matter, storyboards are just a way to define your view controllers and navigations via segues. If you're doing a custom animation, your View Controller still segues as normal, it just does so with a custom animation (instead of one of the stock ones, like a Navigation Controller "push" or the various Modal VC presentations), which you provide via an animation controller - an object that conforms to UIViewControllerAnimatedTransitioning.
Storyboard, or XIB? They are different.
The simplest thing to do is probably to create your view and get it set up in it's final position inside the view controller. Hook up an outlet to your view in your view controller.
Note the Y coordinate of the view when it is at the location you want it. Then use the size inspector to change the y coordinate of the view to the bottom of the view. (768 for a landscape iPad app, 1024 for a portrait iPad app, etc.)
Then attach a swipe gesture recognizer to your VC's content view, and in action for the swipe gesture, use a UIView animation method (animateWithDuration:animations: or a similar method to move the view's frame.origin.y up to the y desired y coordinate.

How the view and viewcontroller hooked?

I cannot find where the view and viewcontroller get hooked? Is it in the xib file?
I learned that each viewcontroller can control several views, but where are those two get hooked?
I recommend you to read the whole ViewController Programming Guide if you have doubts like that:
ViewController Programming Guide
In case you want to jump right to your issue, check this section:
Resource Managment in ViewControllers
You can find a nice graph explaining where the views are created and linked in the ViewController:
A ViewController is just that, a class to manage the UIViews (there will be many) that it contains. The main view is automatically wired up for you and you are responsible for wiring up all the other views you add. Keep in mind that UIButtons, UILabels, UIViews, etc are all objects that inherit from UIView.
Like Antonio indicated, start with the Apple docs:
The view controller has its own view. Each child view (subview) view has a parent view (superview). You can nest views inside of views. In your case, the top view in the hierarchy is the view controller's view.
At design time, you can add a child view to any view in Interface Builder by simply dragging a new view onto the parent view. You can also adjust the view hierarchy from the Document Outline in Interface Builder.
When creating a view hierarchy in Interface Builder, the view hierarchy is stored in the .xib file.
At run time, your views are instantiated from the information in the .xib file, and each child view's superview property points to its parent view. Each view also has a subviews property that lists each of its child views.
You can add a view to any other view at run time by instantiating a new view and passing it to the parent view's addSubview method. Obviously, once instantiated, you can alter the view hierarchy by setting the superview and subviews properties and calling related methods.

Resources