storyboard viewcontroller to coded viewcontroller - xcode

Is it possible to connect Storyboard ViewControllers with manual code-written ViewControllers? What I'm trying to do is make an app that, when internet connection is established, I see the viewcontroller made in the storyboard with tools given in the xcode (like the stepper, progress view, and etc) and when there's no internet connection, I want to access my coded viewcontroller that doesn't use the provided storyboard. How do I make the transition from the viewcontroller in the storyboard to the one not in the storyboard? Thanks!
UPDATE:Image depiction of what I seek to find:
depiction

I believe what you wanna do is show a storyboard programmatically?
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "ViewController")
window?.rootViewController = vc
Don't forget to add the "ViewController" identifier to the ViewController in your Interface builder.

Related

Navigation Controller crashing app

Within my app I have a UIViewController and a UITableViewController.
I wish to navigate from the UIViewController to the UITableViewController.
Within the UITableViewController I want a navigation bar so that I can 'add' items and declare when I am 'done' so that I can travel back to my UIViewController.
To achieve this I have embedded the UITableViewController within a UINavigationController as this reveals the navigation bar which I can add my buttons to and add a title.
I have 'control dragged' a segue from the UIViewController to the UINavigationController, which itself is attached to the UITableViewController.
UIViewController -> UINavigationController -> UITableViewController
My intended functionality is to travel from the UIViewController to the UITableViewController. However, the app crashes with the following message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x7f96c1451890>) doesn't contain a view controller with identifier 'UINavigationController-IxO-nE-zon'
The app does not crash if my segue is directly attached from the UIViewController to the UITableViewController (with the UINavigationController gone). However, then I do not get my Navigation Bar at the top of the UITableViewController which I need.
So my question is either: can I fix this error so that I can travel between them, or is there another way of doing this so that I can travel between them whilst keeping my navigation bar.
Thank you!
Okay, turned out I had the setup correct but I required a project clean before it worked. I guess because I added the storyboard ID's after adding the segues.
Thank-you to the following answer: Answer

Reference main NSWindow in AppDelegate using Storyboard?

I am attempting to set an outlet for the main window of my app in my App Delegate, then connect it within Interface Builder. I create the outlet within my App Delegate easily:
#IBOutlet weak var mainWindow: NSWindow!
However there's no way, within interface builder, for me to connect a referencing outlet to the App Delegate. Instead, I can only connect it to the Window Controller, which I hope this picture shows:
The first object is the Window Controller and the second object is the First Responder, however the App Delegate object is missing. The menubar has the App Delegate object:
And I can connect anything from the menubar to any outlets in the App Delegate.
I figure I can access the window object by using:
NSApp.windows[0]
But that seems prone to error, especially if I have more than one window.
I dont know if this is correct way of doing, but this will solve your problem.
Decalre a NSWindow property in AppDelegate
weak var window: NSWindow!
and set the property in something like windowWillLoad of the NSWindowController
(NSApplication.sharedApplication().delegate as! AppDelegate).window = self.window
You will have to subclass NSWindowController to define windowWillLoad

How to add an outlet between a storyboard and an NSDocument

I've done iOS for a few years, but I'm new to OS X.
I'm using the document-based template in Xcode 6. I added a textfield to the view controller in the storyboard. How do I access it from the Document?
I added:
#property(nonatomic, weak)IBOutlet NSString* aString;
to Document.h. When I drag to it, IB seems to be forcing me to use bindings. OK with me, but I'm still very weak on bindings. The dialog box asks for a number of values, most of which I can guess. But, what does "Custom Class" mean, and what should I put there?
A little help here would certainly be appreciated.
Thanks
You don't. The IBOutlet for the textfield should be in the NSViewController subclass (ViewController in the template Xcode project).
Your next question will be "How do I access the NSDocument from my view controller?"; Mac App Storyboard - Access Document in NSViewController ;-)

xcode 4.2 storyboard, segue by code

I'm trying to make the segue between a button created by coding and a view created in storyboard?
(the button is not in the storyboard, it's made inside the viewcontroller .m class)
please help if you know the solution
thanks,
If the current view controller (the one that owns the button) came from the storyboard, you can just use the performSegueWithIdentifier:sender: method of UIViewController, like this:
[self performSegueWithIdentifier:#"mySegue" sender:sender];

Splitviewcontroller xib after viewcontroller in xcode

i want to put splitviewcontroller xib after the viewcontroller xib in ipad version.i tried to search but it only shows to set splitviewcontroller xib from MainWindow..but i want to put normal view controller xib in starting and after that splitviewcontroller xib should be call.
any help will be appreciated
thank you.
i think u want present modal view controller for that.
as a new bee take a look at this to
http://mobileorchard.com/new-in-iphone-30-tutorial-series-part-2-in-app-email-messageui/
u have to customize them as u needed

Resources