In my ARKit application ARSCNView is initialized and attached to ViewController internally based on storyboard file structure. So in function viewDidLoad I have already initialized view.
But the problem is it uses default rendering API metal. But I would like to change it to OpenGL ES2. In Apple documentation I read that preferredRenderingAPI can be somehow changed in IB inspector. But I don't understand how. There are no any examples of how to do this?
Or maybe I still change it from the code, even though the view is initialized from IB?
Just open your Main.storyboard (or whatever you have) in Xcode and navigate to the node Scene View of type SCNView in there. The Attributes inspector should allow you to change the renderer (Rendering API).
I've just tested it but it looked like my project didn't work the same as with metal.
Related
I was following raywenderlich's Metal tutorial, but got stuck rendering a texture on a plane, it seems to be showing only one color of the image, not the entire image. I'm running on an iPad iOS 12.3.
Here's a repo for the project: https://github.com/TheJoseph-Dev/MyMetalProgram
May anyone help me?
In your Renderer implementation, set a breakpoint on the line that reads:
private lazy var device = metalView.device
And run your code.
At the point in which this line is executed, the metalView exists, but the device on that metalView is nil. Similar problems can be seen for the other lazy properties of the renderer.
You may wish to use a less complex property style as it appears the properties are not being collected when the view is in the state you expect. I suspect that the view will not create resources like its device until it is attached to a window which will happen after viewDidLoad.
I made a game for iOS using SpriteKit.
Now I wanna make also the version for watchOS.
I added a new target and then these files appear to me:
If I delete the sks file and then try to present a swift scene as I did for the iOS game the scene appears empty... So the only thing i could do is leave the scene.sks file as it was.
Can someone kindly explain to me how can to present a new scene.swift file in the interfaceController.swift without using the sks file?
Here is the InterfaceController.swift file that presents the sks scene, but I wanna present my own swift scene.
Best Regards.
exchange the GameScene(filenamed:) with `YourScene(size:).
Your scenes are a subclass of SKView which have their primary initializers... here is the link to the one I showed:
https://developer.apple.com/reference/spritekit/skscene/1520435-init
So (filenamed:) is one initializer (for .sks) and (size:) is another initializer, for not having .sks. These initializers are the exact same kind of initializers you use for all of your own classes.
This just isn't readily apparent, because when you make your own GameScene: SKScene you don't specify initializers (because they are inherited from SKScene that you just subclassed from)
the video below also covers most of the necessary things for SK on AW.. it's timestamped to explain more of what you're doing:
https://youtu.be/REv-w2rBsng?t=1173
the info in the above video is virtually nowhere else that I could find, so I highly recommend you watch it from begin to end.
NOTE:
(last I checked)
Your vanilla SKScenes won't work on the watch, because they lack certain functions (like touchesBegan) because you are no longer using an SKView to present your scene. So, you must use gesture recognizers..
Here explains how to get around that stuff:
TouchEvents in watchOS 3 SpriteKit?
I'm working on a large ios app and I'm also a newb. I'm trying to find the correct scene in a storyboard in a large app. I'm in the .swift file and I need a quick way to figure out which scene is associated with that swift controller file. The only way I know now is to go through each scene and look at the Class property, which will take forever. Is there a shortcut to jump from the swift file to the associated scene?
In Xcode, open "Find in Workspace..." (Command+Shift+F)
Type the name of your ViewController.
In the results panel, check the entries under the .storyboard file. Clicking on them will open that exactly scene in the Interface Builder.
Profit.
You can also go further and filter the search by filetype. Check this out:
Create a custom Scope:
Super awesome result:
I have recently started to learn iOS with obj-c from "iOS Programming The Big Nerd Ranch Guide 4th Edition". This edition was released in 2014 and is written with Xcode 5.
I am trying to make a simple app with two buttons and two labels. The labels are connected to two arrays and when a button is pressed an object from the corresponding array is shown in the corresponding text label (it's the Quiz app in chapter 1).
I created the project as a Single View app in Xcode 6, and put all my objects in the view controller class. I have two labels two buttons two arrays and an int to keep track of the object that has to be displayed from the array.
In the book it says that I should initialize the arrays in the initWithNibName method. I tried that but for some reason it never gets called. So I changed the initialization of the arrays to the init method. They initialize fine but when they are called from another method they are nil. Do you have any idea why this is happening?
The second issue I'm having is that I can't manage to get the contents of the storyboard on screen. It says that I'm supposed to make an instance of the ViewController inside the AppDelegate and make it the root window controller but all I get is a white window (or black in case I don't set the color).
UPDATE: I changed the intialization of the arrays from the init method to the viewDidLoad method and now they seem to be working fine. Nothing on the screen though.
It sounds like you're initializing your UIViewController from the app delegate AND a storyboard. If you create a new project in XCode, a "Single view application", you won't have to touch the app delegate at all in order to get something on the screen.
I believe both your problems are related to this, since it sounds like you're seeing an empty UIViewController on the screen (the one you create in the app delegate)
As for the initialization of your array, viewDidLoad is a popular place to do this.
If you are using storyboards, the method initWithNibNameOrNil will not be called. In the BNR book, it teaches you to use XIB files, which do use this method. If you are trying to follow the tutorials, I would suggest using XIB files.
For use of a book, I would suggest downloading whatever version of Xcode is being used for that book -- otherwise you will be running into a lot of confusing problems while learning.
If you would like to download previous version of Xcode, refer to this post:
How to download Xcode DMG or XIP file?
So I'm creating and showing a custom window in my iOS app because I'm writing a dynamic alert view that also functions like a growl/toast alert. It works AWESOMELY in ios6 (Hopefully I can open source this baby and you can all check it out)
But anyway, when I run this in ios5, the window that my alerts exist on doesn't seem to rotate with the device/simulator. No matter what, my custom window stays in portrait mode.
The UIWindow is just a UIView subclass, so there's no nice 'shouldRotate' delegate method.
I'm kinda stumped on why this is happening in ios5 but not 6. Any help would be GREATLY appreciated ^_^
My window has a rootviewcontroller, which I completely forgot about. I just needed to implement
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
To get it to work.
:-D
It's usually not recommended two use multiple instances of UIWindow in one iOS app. The only valid reason to do so is to support external screens. You should use a UIView instead, ideally managed by a UIViewController.
I assume, (since you didn't provide any code, I can only assume) the reason why your window doesn't 'rotate' is, that it's simply not getting any notifications about device rotation. Only the keyWindow receives them by default.
I would highly recommend to redesign your app to use a properly managed UIView instead. If you desperately don't want that for some reason, you would have to register your instance of UIWindow to receive the UIDeviceOrientationDidChangeNotification and then (in the handler) evaluate what the new orientation is and change the window's frame accordingly (plus maybe other things that need to be done in response to the orientation change)