Inheriting from uitableviewcontroller crashes app - ios

I dragged a view controller into my app then created a new view and made it segue to that view. I created a class for that view and made it inherit from uitableviewcontroller but when I segue to that view the app crashes terminating with uncaught exception of type nsexception. Is this because the view is not a table view controller? Or am I missing something else? Thanks.

I bet it crashes because the tableViewController expects its root view to be a tableview and you embedded the tableview in another view

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.

Unrecognized selector sent to instance when connecting Navigation View Controller via root view controller to Detail View Controller

I want to start with a DetailViewController, not a Table View.
So, first I create a Master-Detail Application.
Then, I remove the Segue
Control-drag from Nav Controller to Detail View Controller and select "root view controller"
Nav is now directly connected to Detail View Controller
unrecognized selector sent to instance
I'm confused because I've always done it like this in XCode5... And now it doesn't work anymore?? Some help is much appreciated guys :).
Update: When UNCHECKING Core Data at project creation, it doesn't happen. But I do need Core Data!!
It seems that someone is trying to call setManagedObjectContext on a DetailViewController instance and this method doesn't exist. Thus resulting in a runtime crash.
Had almost similar issue (With view controllers). If you have some view controllers with segues connected and data transfer happens in between. Make sure the data to the required view controller is set with the prepareForSegue separately for each destination view controller.

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.

how to include the leah PullRefreshTableviewController in a UIViewController?

I have to include the leah pulltorefresh table view in an existing ios project. (https://github.com/leah/PullToRefresh)
The existing table view is defined in a xib file and it's linked to an outlet in the controller class (a subclass of UIViewController).
My first try was to make the controller inherit of PullToRefreshTableViewController (from leah's project) and add the refresh fonction in that same controller. But it doesn't work, I have this error :
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "CampaignViewController" nib but didn't get a UITableView.'
Since PullToRefreshTableViewController is a subclass of UITableViewController, I think I can't make my controller inherit from it (am I right?). How can I do this? Thanks
Try creating TableViewController from scratch, making it a subclass of PullToRefreshTableViewController.
It's much simpler than creating a table view in IB, connecting outlets, and then filling all necessary delegate and datasource methods.

Resources