I have a UITabBarController that has 3 tabs. Each tab contains a UITableViewController. When I add a subview to one of the UITableView's and then switch to another tab I get the error:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<MessageTableViewController 0x703f6b0> setValue:forUndefinedKey:]: this class is not key
value coding-compliant for the key emptyView.'
emptyView is the subview that I added. I am not sure why the new view that is being switched to requires emptyView?
UPDATE:
I am adding to emptyView by:
[self.view addSubview:emptyView];
in my viewDidAppear method.
MessageTableViewController is the rootview for the tab I am navigating to.
I am also noticing that no matter which tab I navigate to, I get this error. emptyView is only in the NIB for 1 of my VC's. Not all three. Each tab has its own unique VC.
This is a common error received when you have changed or deleted a property from that class, and did not update the connections in Interface Builder. It also happens when your File's Owner does not have the correct class identified.
You may want to try checking both of these items in Interface Builder, to see if either are creating this error.
Try checking to see if the class is set correctly in Interface Builder identity inspector.
You will then want to look under the custom class heading to see if that objects class is set correctly.
Related
I'm working on a Storyboards based app which constitutes of multiple view controllers linked via a Navigation Controller (initial view controller). This is used as the home screen. I'm using static cells and a static table view.
Now, I want to hook up some labels, buttons, etc as outlets/actions to "the .h" file and subsequently write custom methods in the .m file. But (as expected?) there's yet no custom class to select from in the identity inspector. So I created a new custom class as a subclass of UITableViewController (which seems to be the correct one?)
My new, custom class is now hooked up to my storyboard view controller. I then enter (what I believe to be) the correct numberOfSectionsInTableView: 1, and numberOfRowsInSection:5 (I got 1 section including 5 rows). When ran, it immediately crashes with the following error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
If return 0 sections and 0 rows, everything works fine (expect there are no rows displayed). Once I return anything > 0 in either of them, it crashes with this error.
What have I missed? Is there anything else I'm supposed to add to the file before it can be attached as a custom class and I can use it as any other custom class? Again, I've set up everything in the interface builder (storyboard), including the table cell rows, its styling, etc. What am I doing wrong?
My Table View Setup
My Table Cell Setup
Pretty sure this is the answer: in storyboard, make sure a prototype cell is painted on the table view (the one in the crashing view controller) and make sure it has a reuse identifier set to "Cell". Your code for rowAtIndexPath: is trying to dequeue a cell with that identifier and it's not there.
The identifier can be set using the attributes inspector (the middle tab on the upper right) in storyboard.
I have created an empty application and then added a window to it(made a window based application).
Then i added tabbarcontroller to it and navigation controller inside the tabbarcontroller. I have added nib files to my application for each tabs and given the nib names to viewcontrollers.Then i added a button to one of the nib file ,then application is crashing and giving error like -
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[ setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key btnNext.'
-----i have connected the iboutlet of buttons too.then why this error?
This error happens when the IBOutlets are not wired correctly. One common example is if you were to wire an IBOutlet in Interface Builder, but then delete the corresponding property in the corresponding class (where the IBOutlet was defined). Obviousily that's a mistake when that happens, but unfortunately Xcode will not give you a compile time error, and instead gives you this vague runtime error. Take a look at ALL IBOutlets in the relevant Interface Builder files and make sure they match up correctly to the IBOutlets in the header files (both in type and presence).
What you need is to add navigation controller to tab and inside the navigation controller in (view controller) you need to put the class name of view controller. Hope this link will also help you.
I'm having a problem similar to the one discussed in this thread, but the solution provided to him isn't working for me. I apologize for the lengthy description, but this is my first post on SO and I want to be complete.
I have a program that runs fine in the simulator. However, when I try to push it out to the device, I get an error that says this:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/....app> (loaded)' with name 'MainWindow''
So: it's trying to load a XIB called MainWindow, but it can't find it. That's because I don't have a XIB called MainWindow; the first XIB I load is called FrontPage.xib. I didn't start this program using one of the templates and thus was not provided with a MainWindow.xib file at the beginning.
The Google machine tells me that the Main nib file base name can be modified in my app's plist. So, I go there and I change it to FrontPage. Now, I get a different error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x12c270> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
I'm pulling my hair out over here - anyone know a solution?
Make sure that your view is connected to your "View" outlet in Interface Builder. You do this by right clicking on your "File's Owner" in IB and then dragging to the "View" outlet to your View. Here's an illustration from a game I'm working on. Notice the blue line, dragged from the dot on the right to the "view".
Another thing you will want to check is your Info.plist. Make sure that you have called your nib file FrontPage and not *FrontPage****.nib***.
If Frontpage.xib is going to be your application's main xib, then you have to create a Window object and an App Delegate object in that xib in order for the app to be able to load. Before you can start presenting view controllers and such you have to configure the app and the window or it will crash as you describe. I would suggest creating a new project using a Window based template and just take a look at the MainWindow.xib that gets created automatically and try to mimic it in your Frontpage.xib..
.. Although I would just sincerely suggest using a MainWindow.sib in your project and making your Frontpage.xib a normal view controller xib. If you choose to add a new file to your project, then choose User Interface, then choose Application xib instead of View xib, then it will set you up with something close to what you need.
The project templates are important and useful. You should always use them. I start all of mine with a Window Based template. It is the most basic template and the most flexible.
If the view controller for FrontPage.xib is set properly by setting the File owner property via IB then you also need to set the view property. you can do this by control dragging from Fileowner to the view. From the error it appears that you have yet not set the view property for your view. Open the nib in Interface builder and and look for the View Connection in connection Inspector , this must be connected to file owner's view outlet. You don't need to declare it as a property anywhere.
I have a tab bar item with a UIScrollView and all the code works.
I link the UIScrollView IBOutlet in IB to a UIScrollView I placed in my View.
When I run the app and select the tab bar item I get the following error.
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key scrollView.'
I have no idea what this is. When I disconnect the ScrollView IBOutlet, then there is no crash.
Thanks
You probably renamed the name of the scrollView in the code without re-connecting the outlet in Interface Builder. Double check your code to make sure the spelling is the same as in Interface Builder, and for good measure, reconnect the outlet to scrollView.
Referring to this Apple forum thread, UITabBarController has multiple UIViewControllers each of which has its own nib file assigned to it. It's up to you to make sure you change the UIViewController's class file: in the nib file for each view controller and in the tab bar controller's nib file, you also have to do the same thing by changing each view controller's nib file and class.
So all in all you have to update settings in two places: the individual nib files for the view controllers and the tab bar controller's nib file. Think of it as creating the connections/bridges between the individual nib files and the tab bar controller.
Once these connections are made, your program should have no problem accessing your scrollView outlet, since that is how it ultimately accesses it: by using key-value coding by means of your tab bar controller (at least, that's my understanding). As of now it can't because the tab bar controller is not connected properly.
I created a tab bar application, and I make the first tab a table. So I create a tableView controller, and go about setting the class identity of the view controller for the first tab to my tableView controller.
This works fine, and I see the contents of the table filling up the whole screen.
However, this is not what I actually want in the end goal - I would like a compound window having multiple views:
- the aforementioned table
- a custom view with data in it
So what I do is create a nib for this content (call it contentNib), change the tab's class from the tableView controller to a generic UIViewController, and set the nib of that tab to this new contentNib.
In this new contentNib I drag on a tableView and set File's Owner to the TableViewController. I then link the dataSource and delegate to file's owner (which is TableViewController).
Surprisingly this does not work and I receive the error:
**Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x3b0f910'**
This is bewildering to me since the file's owner is the TableViewController, which has been assigned to be both the dataSource and delegate. Does someone have either insight into my confusions, or a link to an example of how to have a compound view include a tableView?
*****update**** I see this in the Apple TableView programming guide:
"Note: You should use a UIViewController subclass rather than a subclass of UITableViewController to manage a table view if the view to be managed is composed of multiple subviews, one of which is a table view. The default behavior of the UITableViewController class is to make the table view fill the screen between the navigation bar and the tab bar (if either are present)."* <----- I don't really get what this is telling me to do though... if someone can explain or point me to an example I'd be much appreciated!
The File's Owner should be a class that you instantiate. For example, in your contentNib file, you should alloc and init a table view, passing the #"contentNib" as the argument to initWithNibNamed:bundle:. It sounds like you're not doing this, as the File's Owner, while set in IB to a UITableViewController, is actually just a UIViewController.
The setting in IB is just to let IB know what outlets and actions to make available; you are responsible for providing the proper object.