ios - 应用程序在设备上崩溃但在模拟器中没有崩溃 :[UITableViewController loadView] loaded the "XXXViewController" nib but didn't get a UITableView. '

标签 ios iphone objective-c uitableview

在 IOS 模拟器上运行我的应用程序时它工作正常,但如果我在我的设备上运行它,我会收到下一个错误:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "XXXViewController" nib but didn't get a UITableView.'

这可能是一个错误,因为它在 iOS 模拟器中运行。 有谁知道如何解决这一问题?

我已经将我的 View Controller 设置为

@interface XXXViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate>

我以编程方式创建了 View ,因此没有 xib 文件(也没有 Storyboard)。

最佳答案

添加

- (id)initWithStyle:(UITableViewStyle)style
{
    return [self init];
}

解决了问题。正如我在

-(id)init
{
    // Call the superclass's designated initializer
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
...
    }
    return self;
}

关于ios - 应用程序在设备上崩溃但在模拟器中没有崩溃 :[UITableViewController loadView] loaded the "XXXViewController" nib but didn't get a UITableView. ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20974341/

相关文章:

ios - 将 flash 项目转换为 flex 项目

iphone - 如何在 iOS 5.1 及更低版本的 UILabel 中创建多色文本

iphone - Rails 和 iphone native 应用程序之间的套接字连接

iphone - 从 ALAssetRepresentation 设置 CGImageRef 的最大尺寸

objective-c - 未找到体系结构 i386 的符号

ios - 为什么我的 segue 导致 "unrecognized selector sent to instance"NSInvalidArgumentException?

ios - 禁用 RightBarButtonItems

ios - 如何从我的iOS应用中删除推送通知?

iphone - 如何在应用程序进入前台时刷新 UIWebView?

ios - 从 SKScene 获取命令键