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];
Related
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
In the new Xcode 7.2 (iOS9), how do I add a viewcontroller.swift file and link it to a manually added view controller in the storyboard?
(This seems to be different than previous versions of Xcode where one would manually add a Cocoa Touch file after dragging a new view controller object in thestoryboard.)
Thank you.
It has always been the same for me but here are the steps that I follow.
Right click the file explorer on the left
Click Source->Next->Subclass UIViewController
Drag UIViewController into Interface Builder
Click the yellow circle to focus on the UIViewController
Click the Identity Inspector
Set the Custom Class to the name in your Swift File
Whenever I add a Navigation controller to the xcode storyboard there is a tableviewcontroller added with a "relation" connecting the two and I don't want a tableviewcontroller, I want a regular viewcontroller. How do I get that? I am trying to reproduce the following Apple PhotoPicker sample in a storyboard.
Easy:
Drag a ViewController onto the storyboard, then click "editor" and "embed in". Choose NavigationController.
Done.
I have a UIViewController subclass that I created previously that had its controls laid out in a XIB file.
I'd like to use this view controller in a storyboard now, but it seems although I can indicate a view controller's classname in the storyboard, I can't tell it to load the XIB.
I'd rather not move everything from the XIB to the storyboard but keep it in its separate XIB.
How can I get this UIViewController in the storyboard to load my XIB?
Delete the View contained by the view controller in the storyboard.
Then provide the view by configuring a nib file with the same name
as the view controller class. For example if the view controller
class is called MyViewController, name your xib file
MyViewController.xib.
EDIT Note that Swift seed 5 started breaking this technique, because it mangles the name of the .xib file it's looking for. See my answer here for workarounds: https://stackoverflow.com/a/25539016/341994 Basically this name matching was broken in iOS 8, but then Apple repented and fixed it so that it works again in iOS 9.
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