Subclassing a UITableViewController without nib or storyboard? - ios

I'm trying to subclass UITableViewController just with just code without a nib or storyboard. Upon loading its view I get this error:
'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "BYZ-38-tfr-view-1bC-Xs-vdC" nib but didn't get a UITableView.'
I've tried setting self.tableView with a new table view in :loadView but that doesn't fix it, nor does setting it in any initializers. Any solutions?
Edit: The class is a plain subclass of UITableViewController generated from the "new file" menu. No customizations have been made.
It may help to note that the project itself has a storyboard, and I'm loading the UITableViewController subclass by making the app's starting view controller to be the subclass.
The error is easily reproducible by creating a new single-view template project in Xcode, generating a plain UITableViewController subclass, and setting the only view controller in the storyboard to be of the UITableViewController subclass type.
Edit 2: Problem solved, check comments.

I fixed it by avoiding any storyboard whatsoever. Originally I had it being loaded via the projects main storyboard. Instead, I now load up the subclass instance in a separate view controller, avoiding the error.

Related

How do I avoid using the [UITableViewController loadView] when trying to present a UIViewController (and not a UITableViewController)

I am making an iPad app that, among other things contain a view in which to set options.
This "Options" View has two container-views, each holding a TableView with two different kinds of options in them, and switches to turn these options on or off.
The problem is that when I try to make a button from my main ViewController that will open the options view, I get the following error:
Screenshot of signal SIGABRT error
with this in the output:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-c2d-Su-6Id" from storyboard "Options", but didn't get a UITableView.'
I don't know why the underlying function [UITableViewController loadView] is used, as I do not expect my Options-view to be a TableView - the tables are in container views.
I am using different storyboards, and a segue to a storyboard reference to present the Options View modally. I have tried deleting both the button, the segue and the Storyboard reference, replacing them with new ones, and renaming my ViewController.swift file, and all the references to it, with no luck
I have also tried looking for other solutions here on the site, but I have had no luck, and I begin to fear it might be because of the tableViews in the containerViews...
I am quite new to learning swift and Xcode, so please keep your explanations simple to follow, and assume that I am completely incompetent :-)
I'm guessing you probably added a Container View, which automatically places a "child" view controller onto the Storyboard, and then simply changed the Class of that child VC to UITableViewController --- which, as you found out, doesn't work.
To use a table view controller as the child, add your Container View, then add a normal UITableViewController to the Storyboard. Then, Ctrl-Drag from the Container View to the new table view controller and select Embed from the popup menu.

UITableViewController inside a UIViewController with swift and Xcode 8

I have a problem similar to this:
UITableViewController inside a UIViewController
I follow exactly the same steps.
I have a UIViewController with my custom class: MyCustomClassViewController and UITableViewController named MyCustomUITableViewController.
Inside of my ViewController I added a Container View and drag and drop to my UITableView and selected embed.
Ok, now, when I executed the project, I got this error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'containerView is
required.'
Your view controller classes are incorrectly constructed. Look at your embed segue, and make sure that:
The source view controller is marked in the identity inspector as MyCustomClassViewController
The destination view controller is marked in the identity inspector as MyCustomUITableViewController
Also go back to your code and make sure also that you have the correct inheritance:
MyCustomClassViewController should be a UIViewController subclass
MyCustomUITableViewController should a UITableViewController subclass
You might even have to delete the segue, and even the view controllers, from the storyboard, and recreate them along with the container view and the embed segue.

Does anyone know how to use UITableViewController to implement UISearchController in Xamarin.iOs without using StoryBoards?

I am trying to implement UISeachController through a UITableViewController in Xamarin.iOs. I have created an XIB file in XCode and then have implemented the UITableViewController in the .cs file.
When I go back to the XCode designer view, I am unable to set the File Owner View Outlet, which causes the application to throw an exception which says -
Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: -[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SearchViewController" nib but the view outlet was not set.
Any help will be deeply appreciated.
Set the referencing outlet of main view in your SearchViewController

nib but didn't get a UITableView using PFQueryTableViewController

I am trying to add a search feature to my app but the screen needs to have a navigation bar in addition the search bar on the UITableView. I am getting the following error when i perform the segue (click a button) and the view loads
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "2Gx-ec-tTH-view-HBf-bD-79u" nib but didn't get a UITableView.'
Here is what it looks like on my storyboard.
I believe the problem is that this scene is managed by a class called "AllDataViewController" and it manages the UIView and is a subclass of UITableView it is actually PFQueryTableViewController
//AllDataTableViewController.h
#interface AllDataTableViewController : PFQueryTableViewController <UISearchDisplayDelegate, UISearchBarDelegate, UITableViewDelegate>
So I am not sure what I am doing wrong here. But let me know if you have any suggestions or if I need to add any more information.
Because your view controller subclasses UITableViewController (well, indirectly via PFQueryTableViewController), it expects its view property to refer to an instance of a UITableView. If you look at the object hierarchy in the storyboard scene I think you will find that the root of the scene is not a UITableView, but a UIView.
How did you add the navigation bar? The correct method is to select "embed in..." from the Editor menu in Image Builder.

Issue with Uicollectionview for nib but didn't get a UICollectionView

I am new for IOS development , and I try to use UIcollectionView to show the photo.
I create a xib file from New file -> iOS -> User Interface -> View , and add a Collection View like the following picture.
But I got the following error log when it crash.
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UICollectionViewController loadView]
loaded the "AITLocalGridViewController" nib but didn't get a UICollectionView.'
And it seems didn't call viewDidLoad
I have search for some information , some information indicated that I dint not connect the collection view in xib file
But I don't understand what it mean.
Could some one help me and teach me what to do ?
Make sure that you have connected UIcollectionview IBOutlet with “collectionview “ that you declared in your program. And also you should make delegate&data source connection(For making this, click on th Uicollectionview in the xib. Select Connection Inspector. Where you can see delegate and datasource.By pressing ctrl button drag and connect it to File’s Owner.)
Just remove the view in Storyboard and use the UICollectionView as direct child.
Make sure UICollectionViewController's "view" outlet is set to a UICollectionView. Setting the "collectionView" to a UICollectionView is not enough for a UICollectionViewController.
At the risk of stating the obvious, also make sure that the UICollectionView is inside a UICollectionViewController. This can be overlooked when you do something like adding an embedded view into your project, where the default embedded view is the standard view controller.

Resources