I have a custom UITableViewController ("ChatView") that has an Output for a tableView. In the interface builder I have connected the tableView in the nib to the outlet. When the view loads I get the above error. The view is loaded via a tabcontroller.
I have done some research about the error and I can't seem to track down the issue. I would appreciate if someone could get me going in the right direction to resolve this.
@interface ChatViewController : UITableViewController
<UITableViewDelegate, UITableViewDataSource> {
NSMutableArray *chatMessages;
IBOutlet UITableView *chatTable;
IBOutlet UITextField *chatText;
}
@property(nonatomic, retain) IBOutlet UITextField *chatText;
@property (nonatomic, retain) IBOutlet UITableView *chatTable;
@property (nonatomic, retain) NSMutableArray *chatMessages;
-(IBA开发者_运维百科ction)sendPressed;
@end
Thanks
Had a similar problem. The runtime dump was saying:
loaded nib but didn't get a UITableView
I had hooked up everything fine on the storyboard. I had a viewController as the main class and had a UITableView object with a custom cell inside.
However, the problem was that my custom class had 'somehow' ended up being a UITableView instead of this:
@interface iPadDetailViewController : UIViewController <UITableViewDelegate> {
IBOutlet UITableView *tableBox;
}
Once I managed to match up the storyboard type with the custom class type it was all fine.
The moral of the story, xCode and the compiler is usually right. Check your classes match.
If your class is a UITableViewController
then the view
outlet must be connected to the table view. If you want a view that contains a UITableView
then simple make the controller a UIViewController
which conforms to the UITableViewDelegate
and UITableViewDataSource
protocols and this will go away.
ChatViewController
is a subclass of UITableViewController
, that's why, the compiler assume that its view property is a UITableView
, however it wasn't, that's why you got that crash. A UITableView
object must be linked to your File's Owner
:
Well - in fact, an UITableViewController is no UITableView. Thus, the error message is correct... I don't know your code, but should ChatViewCotroller not be in fact a ChatView and be based on an UITableView?
In the MainView.xib I set the view controller to be a "Table View Controller" in the Tab Controller Attributes properties. This fixed the problem.
In my case, my view controller really wasn't a UITableViewController. I THOUGHT it was because I had made it look like one on my storyboard. In fact it was a navigation controller and I had dropped a UITableView on it.
The way I was able to discover that it was in fact not a UITableViewController was by looking at the .storyboard
file in a text editor. It's XML that's pretty easy to read. To solve the issue, I dropped a UITableViewController on my storyboard, copy-and-pasted everything from the navigation controller I had been using, and then deleted the navigation controller.
I also ran into the "loaded the _____ nib but didn't get a UITableView.'" I don't know what caused it but it resolved itself for me when I simply moved (like move a few pixels right then move back to original position) the offending Scene in my storyboard, saved the file, clean, and build again.
I got this error message as well. What happened to me is that I had control-clicked dragged a View Controller object onto my storyboard but the custom class was actually a UITableViewController subclass rather than a UIViewController subclass.
At runtime, when my custom UITableViewController subclass loaded its view it was expecting a UITableView but it got a UIView from Interface Builder. The fix was to delete the old view controller object from the storyboard and control-click drag a table view controller object instead.
精彩评论