nib but didn't get a UITableView using PFQueryTableViewController - ios

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.

Related

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.

Trying to use PFQueryTableViewController in Swift

All,
I have a ViewController with a TableView in it. In the Tableview I have a prototype cell designed and it has a subclass and its subclassed with PFTableViewCell.
As I have a view controller and a tableview in it, I have created this class on my view controller.
class ViewController: PFQueryTableViewController {
but as its not a tableviewcontroller will PFQueryTableViewController work ? As I am getting horrible errors like :
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "vXZ-lx-hvc-view-kh9-bI-dsS" nib but didn't get a UITableView.'
Any ideas guys ? I need it as a ViewController because there are other things on the screen besides just a TableView.
You can add a container to your UIViewcontroller in your storyboard. It will create a UIViewController automatically. But you can delete it and add your PFQueryTableViewController instead.
After that you can right click(and hold) from the container to your PFQueryTableViewController and connect the both components and choose embed.

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.

Property 'tableView' not found on object

I've got a method that does [self.tableView reloadData] but I'm getting the error Property 'tableView' not found on object of type 'JSONTableViewController *'.
If I make my interface a UIViewController, this happens, but if I make the interface a UITableViewController, then I don't get the error.
However, if I make it a UITableViewController and switch focus onto the table in the app, I get the error Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "Y4P-9F-EJw-view-lhp-ew-nTw" nib but didn't get a UITableView.'
I've been trying to fix this issue for ages now, but I can't figure out a solution.
UITableViewController has a "tableView" property. UIViewController does not have a tableView" property.
If you want a "tableView" property using a UIViewController, you'll need to add one yourself.
E.G.
#property (strong) IBOutlet UITableView *tableView;
Be sure to connect the table view in your storyboard or xib to the "tableView" property.
I've got a method that does [self.tableView reloadData] but I'm
getting the error Property 'tableView' not found on object of type
'JSONTableViewController *'.
The error appears because you don't have any property named tableView in your interface..
If I make my interface a UIViewController, this happens, but if I make
the interface a UITableViewController, then I don't get the error.
That goes fine because UITableViewController has a tableView propery, see here.
However, if I make it a UITableViewController and switch focus onto
the table in the app, I get the error Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason:
'-[UITableViewController loadView] loaded the
"Y4P-9F-EJw-view-lhp-ew-nTw" nib but didn't get a UITableView.'
Please see this answer, you don't have any outlet linked to a tableView property.
You should take a look over a Table View sample implementation.
You have got a nib file for that view controller who's view is a plain view instead of a table view. Also, a normal UIViewController does not have a tableview property automatically. You have two options:
Leave the view controller a subclass of UITableViewController and modify the nib so the "view" outlet on the "File's Owner" points to a UITableView OR just delete the xib file (you would have to do any table view customization in code).
Make you view controller a subclass of UIViewController and create your own tableView outlet. Add a table view as a subview in your nib and connect it to the newly created tableView outlet. In this case you will also have to manually set the delegate and datasource of the table view.

Subclassing a UITableViewController without nib or storyboard?

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.

Resources