Linking a "Table view Controller" in storyboard to load an .xib? - ios

I am making a Table View Controller based iOS app with over 100 cells.
That would be hard to navigate in Storyboard, so is there a way I can link a Table View cell to open an .xib file and then have a "Back" button in the .xib file to link back to storyboard?
I made an empty application to use with storyboards, please help.

Nothing is stoppin you from loading the XIB in code manually. The event tableView:didSelectRowAtIndexPath: is still there.

Related

UIViewController defined in a xib file doesn't load in the storyboard

I'm trying to load a subclass of a UIViewController with its views defined in a xib file into a storyboard. Let's call it a NibViewController.
The point of this approach is to reuse the same ViewController in multiple screens of the app.
I know it's possible to do it manually in the code, but I'm looking for a solution in the storyboard. I've tried suggestions from other topics like this one, but nothing worked. The ViewController is correctly displayed in the simulator but not in the storyboard. Here is the code: https://github.com/srstanic/NibViewControllerInStoryboard
and here is the screenshot:
Am I mistaken to expect the contents of the NibViewController to appear in the storyboard?
Am I mistaken to expect the contents of the NibViewController to appear in the storyboard?
Yes, you are mistaken. Your app is working perfectly so you should stop worrying and just proceed.
By deleting the view from the view controller in the storyboard, you have specifically instructed the storyboard: "Do not make a view for this view controller. At runtime, the view should come from the xib file, not from you."
And that is exactly what does happen at runtime. So just design your interface in the xib file and all will be well.

How to create a separate view in Storyboard to be included programmatically in UITableView?

I have a UIViewController with a UITableView that is fed with data from the local database. When the user first launches the app (after installing) the table view is empty and I display a UIView in the middle of the table view that contains a UIImage, a UILabel and a UIButton (a call to action).
The first version of this view I built programmatically, which was no good to me because every time I tweaked something I had to build the app again. Then I switched to the storyboard but had to drag a UIView to the middle of my tableView. It is working now but I don't like the way it is, I can't edit my table view cells without having to move the UIView out of the table view.
I'd like to have a way to build this view entirely separated from my tableView (or even from my view controller in question) and then reference it in the viewDidLoad call of my view controller.
Unfortunately Xcode does not allow us to drag views directly to the storyboard so I'm pretty lost here.
Please tell me if I haven't been clear enough. I appreciate any help you could give me.
UPDATE: It'd be particularly awesome to me if I could also create a custom Swift class for this view of mine and reference it in the storyboard. And then in my viewDidLoad I could simply instantiate my custom view.
Thanks in advance.
Create a XIB file in which you can drag a view (without a view controller).
In your code you can load the XIB using NSBundle.mainBundle().loadNibNamed("MyXibName", owner:self, options:nil).
In the XIB file you can give the UIView a custom class (like you can do with view controllers in storyboard).
You then of course have to retrieve the view from the array returned by loadNibNamed and cast it to your custom class.

UITableView "Content" field not appearing in XIB file (Xcode 5 & 6)

I'm having a weird issue that I'm really not sure what to do about. The problem is simple: In one Xcode project (both in Xcode 5 and Xcode 6 Beta 4), I see "Content" and "Prototype Cells" when I click on a UITableView in a storyboard file:
However, in another project, these are simply not appearing in an XIB file:
Does anyone have any idea how to get "Content" and "Prototype Cells" to consistently appear in both .storyboard and .xib files? Thanks!
I hope you are looking this UITableView in the Storyboard only.
When I was looking for your problem's solution I found the below observations :
When I Drag TableView over a View Controller / TableViewController to storyboard,
Then I found First screenshot in Attribute Inspector.
When I created a xib file by using File-> New-> File -> Objective C file and selected UitableViewController with interface builder.
Then I found Second screenshot in Attribute Inspector.
I hope this might help you.
Similar Issue Here - beginner here, so my wording may be incorrect (apologise in advance)
Description: When opening Main Storyboard and clicking on the TableView "view controller" icon I don't see "Content Attribute" within the "Attribute Inspector"
Issue: It looks like the actual table within the scene needs to be selected. When in Storyboard view and clicking on TableView view controller icon, this shows the attributes of the scene for TableView, which is not what you want, you want to select the actual table and not the entire TableView scene.
Resolution: I found two ways to select the actual table itself. 1.) with the TableView view controller selected, press the tab key(this cycles you though each object within a scene), until the table is selected. (the table should appear highlighted)
2.) Above the project view, I have the navigation bar, where I see the hierarchical view of my entire project. Like the following: Main.storyboard --> TableView Scene --> TableView --> etc.
Under Tableview I clicked on "Table View" and this highlighted the Table.
For me, method 1 & 2 worked and now I'm able to see the content attribute "Dynamic Prototypes" under "Table View" of the "Attributes Inspector"

Copy and paste storyboard controller into xib file. Supported or not?

I want to refactor out a storyboard controller to a separate xib, for better reusablity.
The controller extends UITableViewController.
I can select the controller in the storyboard, hit Cmd-C, create an empty xib file using the New File wizard, and finally paste the controller into the xib.
It seems to work ok. The UI elements are there, the outlets are there, etc. It forgets the orientation and the size (portrait, Retina 4-inch), but I can easily set that in the properties pane to the right in xcode.
However when trying to use this xib I get a crash with error message:
loaded the "MyController" nib but the view outlet was not set.
When I try to connect Files Owner to the table view (which is the top view in a controller extended from UITableViewController), xcode won't let me connect them.
My question: Is it unsupported to copy-paste a controller from a storyboard to a xib?
You are most likely jamming a tableViewController into a nib and there is no outlet to hook the view to. When you do Ctl-C in the storyboard make sure you copy the UITable not the UITableViewController. If not you can try to manually create the outlet in the controller but you might have to jump through hoops to make it work.

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 :)

Resources