How do I associate a Storyboard UIViewController with my custom UIViewController class? - ios

I'm running Xcode 7 beta 5 and I have a storyboard with a tab bar controller featuring 4 items. Each item is a UIViewController. I created a custom class that is a subclass of UIViewController.
When I go to the storyboard, click on one of the UIViewControllers, go to the Identity Inspector, click on custom class, and try to name my custom class it says,
"Launch screens may not set custom classnames"
Am I doing something wrong? I thought this was the way to associate a storyboard's UIViewController with your custom view controller.

The problem is that you are trying to assign a custom class to launch screen. Launch screens main function is to display a view until application loads (not to implement application logic). You should create a new view controller representing object in storyboard (this one should be displayed after application load) and assign a custom class to it.

As the error message says, custom classes are now forbidden in Launch Screens in Xcode 7. See e.g. here as well

If you are trying to customize your Splash Screen then you can create your first view controller as Splash Screen and then set a custom class there.
To tell the system that not to load launch screen just change the settings as mentioned below...
General Tab --> Launch Screen File --> Select "Main" (Basically it's Main Storyboard).

You can set a custom class to any storyboard component except the launchscreen.xib file.

This worked for me. I deleted LaunchScreen.storyboard and in main.storyboard I added the custom class which did not give any error later. Hope it helps someone else too.

Related

New Swift Application Creates Obj C Files

I am a bit new to iOS development. Am I going crazy here?
I am using xCode to create a paged application. I select new project with the language as swift.
When I go to add a new view to the application it adds a view with Objective C?? Why? I want to use Swift. Am I doing something wrong?
Adding more screenshots, how do I get the second view to show me the Swift code instead of the "UIKit" code?
Working Side...
Not working
3:
It looks like your Assistant Editor is automatically opening the underlying Objective-C header files rather than the Swift files associated with your View Controllers. Try clicking on Automatic at the top of the Assistant editor, then hovering for a moment to see if your Swift file comes up (it should appear above or below the UIViewController.h file).
If you haven't created a subclass for the View Controller you've created in the storyboard, you'll need to do that first, then assign that class to the View Controller in the storyboard. To do this, select File > New > File…, select Cocoa Touch Class, and make it a subclass of UIViewController (don't create a XIB file). Then, in your storyboard, click on your newly-created View Controller (you can select it from within the view hierarchy on the left), open the Identity inspector, and set its Class to the subclass of UIViewController you just created.
If, for some reason, you've created a View Controller class and correctly associated it with the storyboard object and it's still not appearing, you can use the Manual selection in the Assistant editor to drill down to the file you want to appear.

Main interface can not be changed to my own storyboard

I'm happy to know that zero code is needed to create interface for iOS app using storyboard somehow, but failed to show my own storyboard by changing 'main interface' of project setting in XCode.
Launching app brought me to a black screen which is expected to be a tableview within a navigation.
Having set Colorboard.storyboard as interface should add a grey arrow line pointing to navigation controller in the storyboard....however there wasn't such line.
Xcode I am using is 6.3...I am wondering if there is something I missed?
As far as I see you didn't set the initial view controller for storyboard.
In Attributes inspector select the param called "Is Initial Controller"
More details in documentation.

UIViewController in iOS app launch screen

Is it possible to add a view controller to launch screen in iOS?
if yes How could i do that?
I have dragged a UIViewController to the LaunchScreen.xib file its run correctly, but when I changed the class for the view controller in the LaunchScreen.xib from "identity inspector" from UIViewController to myLaunchScreenViewControllerName
I faced this error
Illegal Configuration : Launch screen may not use instance of myLaunchScreenViewControllerName
Launch screen is is not a fully customizable view controller. You cannot specify a custom class name in the storyboard and expect the system to give you the option to execute code at this stage by calling viewDidLoad. Remember, the app hasn’t launched yet

Cant add new xib's to view controller

I am working on one view controller which has three static screens which i m going to show to user for first time when he installs the app, for next time forever i will show him main functional view.
Problem is
When i have created viewController class i never selected xib option.
Now i have added two xib's (iPhone and iPad) in project.First i deleted the present view from it then I have created three static views in each which contains some label and one button in each..
I want to add those views in my view controller's view. and i want to add targets for buttons in those view.
I am unable to reference outlets in my class for all three views
and can't add target for buttons in my viewController.
How can i do that??
Please help......
Solved it..:)
Problem was when i have added new xib file to project.i deleted the present view controller view from xib...thats why xib was unable to find any of the projects view controllers in custom class drop down
When you click on the File's owner on the left while the XIB is opened:
Select the the third icon on the far right, and make sure the correct class is selected under Custom class, the green textfield:
You need to select File Owner then go to the identity inspector in right pan of Xcode where you can select yor Xib name :)

Using Storyboard how to interact with viewcontroller objects

I've reviewed many websites and youtube videos that have IOS 5 storyboarding information. Most of them are pretty basic and only describe how to get started with storyboarding and how to segue into other views. I'm interested in taking it a step further and actually adding custom code to the views contained within the storyboard.
Is the "normal" workflow when creating an IOS app using storyboard?
Create the layout of an app using storyboard (adding views and objects to those views).
Create viewcontroller files (.h and .m), one for each view contained within the storyboard.
Hook up the scenes from the storyboard with your own view controller subclasses by editing the "class" values in Identity Inspector.
I believe I followed those steps, but when I implemented step #3 above and ran my application, I was only able to see a black screen. The view I had created in storyboard wouldn't display.
You have the right steps. Make sure you create your .m and .h without a xib. Post your code for the view controller for your first view to get more help.
yes, this is the normal workflow. have you set the "initial viewcontroller? ?
see this image: http://dl.dropbox.com/u/31437518/Screen%20Shot%202012-01-24%20at%2012.29.34%20AM.png
It sounds like you made a storyboard file but it isn't being loaded.
Do you have the main storyboard setting in the target summary screen filled in?

Resources