iOS Launch screen code not running - ios

I heard about the new feature which xcode 6 brings, that allows you to make a storyboard as a launchscreen.
Now..
Is there a way to control UI elements on the launchscreen story board via a viewcontroller?
(to show a loading screen or something)
I tried it, I simply did a println("Here's the view loaded on the loadingscreen") in the viewdidload on the controller which is referred to the view in the launchscreen story board, but there's no output at all..
What am I doing wrong?

You're not doing anything wrong.
No code is associated with the launch screen. You can't run any logic. It is purely there so that you can use AutoLayout to layout the launch screens for different sizes of device.

You can't specify any class to launch screen and run code there. The storyboard file is only an alternative for multiple splash screens (Launch images). You can use a single storyboard/xib file based launch screen for different iOS platforms and orientations (You can handle that using Auto Layout).
The major point that you need to remember is, at that point the application is not completely launched.
So viewDidLoad or any view life cycle methods will not be invoked.

Related

IOS DEV: Should I be concerned if the Main.storyboard layout looks different from the actual layout?

So for my app, the tableview layout in the iOS simulator when I click run is CORRECT and as I intend. However the layout is not always 100% the same when I view the layout of the tableview in Main.storyboard. When I refresh Xcode(i.e. quit and restart app), the layout of Main.storyboard is what I intend. However, if I play around with orientations/diff iOS devices within Main.storyboard, and then return to my original device, the layout looks incorrect (even though supposedly the math/measurements are correct). Do I need to be concerned?
For reference I followed the instructions of https://www.ralfebert.de/ios-examples/uikit/uitableviewcontroller/custom-cells/ EXACTLY to make a cell (instead of an image, I used a button though). And here is an image of my iPad simulator https://drive.google.com/file/d/152scJF6h12amh-AAycDqpe6TXOzN2y-H/view?usp=sharing vs the main.storyboard simulator https://drive.google.com/file/d/1NvUfMVLk08S8qH4mFraRsQYbDzPdjaBG/view?usp=sharing
However the layout is not always 100% the same when I view the layout of the tableview in Main.storyboard.
It sounds like you might have some missing or incorrect constraints. Take a look at the little yellow arrow icon to the right of "View Controller Scene":
That icon tells you that there are some issues that you need to resolve. Click it and you'll get a list of the particular issues and your options for fixing them.
Do I need to be concerned?
The risk, of course, is that under some circumstances your view won't draw the way you want it to. Start by fixing the issues that Xcode is pointing out, and then test on lots of different devices (or simulators) as you can, in all the possible geometries you might encounter (different screen sizes, orientations, split view, etc.).

porting iPad app to iPhone using one storyboard with one storyboard

i am able to make my iPad app running on iPhone but the iPhone screens doesnt fit all the content in. For example my table view main text is hidden, the buttons are very much spaced from the border. I understand the spacing given in my storyboard files in too big for iPhone screen.
I want to make my app work for iPhone with very minimal changes. I dont want to create a new storyboard and rewrite everything. Please suggest a good way.
Thanks in advance.
You need to make the app Universal, make a single storyboard the main storyboard in both target's project settings and use Autolayout to position your UI elements respective of the device. Look into Size classes to keep your design responsive.

Size classes and Auto Layout confusion with multiple devices

I created my first app without using size classes and auto layout. Now i'll be making a 2nd app but i'll use size classes+auto layout. So pardon my confusion.
In Xcode's, Assistant Editor preview, I will use all the device sizes for the preview, all iPhones and iPad, iPad PRO.
My understanding is I can use 1 Main.Storyboard for all the storyboards of all devices with the preview storyboards.
However, when it comes to coding, can I also use just 1 view controller.h and view controller.m file for all devices?
Of course, if you can use a single storyboard for all the devices, what makes you think you would not be able to use a single view controller?

iPhone app's storyboard does not display correctly on iPad

I've spent a lot of time attempt to research this issue and haven't gotten any results unfortunately.
[edit: being more explicit with my question]
My question is: why are the objects on my view controller not appearing when I run the iPad simulator? The background color of the view controller is displayed. The navigation tab bar appears as well. But neither of the two objects on my view controller appear (which have constraints on them).
[/edit]
If I look at the info.plist I see that I have "Main Storyboard file base name" with a value of Main (which makes sense, as my one and only storyboard is main.storyboard).
When I run the app within the iPhone simulator, all is well. When I changed the simulator to iPad, this is what happens:
Launch Screen appears
View Controller appears with the background color I have chosen in my storyboard scene.
When in debug, I see that it's going through the code to load up my views as it does when running in the iPhone simulator.
The Tab Bar controller's tab bar appears at the bottom of the view controller as expected.
Is this somehow related to the width and height I have selected? I have it set to: wCompact hAny. When I change it to wAny hRegular, the items I had placed in the scene (a UIView and a UITextField) "disappear."
Some background:
I originally created the app as Universal. But what I want, at least for now because I'm still learning, is just an iPhone app that will also run on an iPad (with that 2x option). I changed the Targeted Device Family to iPhone under both the Target and then later under Project.
I know one option is to just make an iPad layout, but I'd really like to know what I'm doing wrong here.
[edit: one solution]
The resolution I took, although I feel it's not the one I wanted, was to change the size to one that iPad supports and then paste the two objects (UIView & UITextView) into the scene that was defined as wAny hRegular. Then I hooked up those 2 objects to their outlets in the View Controller and I now have my app appearing in the iPad simulator.

Xcode View Controller - Horizontal orientation issue

I have got two view controllers on a Storyboard in Xcode. If I Build and run the application with the initial View controller set as the startup item (The app only allows horizontal orientation) then the application in the Simulator is displayed correctly with all the images in the correct place in Horizontal orientation.
However if I add another View controller to the Storyboard (setting this as the startup item). The simulator is run and displayed horizontally however the graphics are being displayed as if the screen is in vertical orientation.
The plist looks correct and also I have tried setting up the simulated metrics to Landscape and Full Screen. However this does not seem to have worked. The display looks correct within Xcode. It is just when I come to run it on the simulator.
I have searched across Google and have come across articles on Rotating iPads and Orientations.
Can anyone help with my issue? Do I need to add any extra code to get my new view controller to be recognised in the horizontal orientation? or is this a bug with simluator?
Thanks
I have found out the answer to the question myself and I thought I would share.
All I needed to do was select the ViewController Class in the Utilities Screen.
I assume by doing this it can invoke the shouldAutorotateToInterfaceOrientation method and also know which way around the screen should be.

Resources