RootViewController上的NSInternalInconsistencyException
我试图创build一个导航stype应用程序,但我想自定义初始视图,以便tableview不占用整个框架,而是embedded在一个子视图,所以我可以一些标签和图像时该应用程序是第一次启动。
我在RootViewController.h
声明了UIView
和UITableView
ivars,并将它们作为属性添加到标准的“ (nonatomic, retain) IBOutlet
”标记中; 在RootViewController.m
,我合成了这两个,并添加了代码,将它们设置为在viewDidUnload
nil
,并在dealloc
释放它们。 (努力成为一名优秀的memory management公民。)我还没有添加任何其他代码。 没有编译警告。 当我试图testing应用程序,它立即(并反复)与消息坠毁:
*** Terminating app due to uncaught exception NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "RootViewController" nib but the view outlet was not set.'
我已经将视图和tableview连接到我的RootViewController
nib中的文件所有者; 当我右键单击对象图中的文件所有者时,我将它们都列为出口。 当我右键单击每个控件时,我将文件所有者视为引用出口。
帮帮我! 我该如何解决?
更新
// // RootViewController.m // rx2 // #import "RootViewController.h" @implementation RootViewController /* I added these two lines */ @synthesize uiView; @synthesize uiTableView; #pragma mark - #pragma mark View lifecycle #pragma mark - #pragma mark Table view data source // Customize the number of sections in the table view. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell. return cell; } #pragma mark - #pragma mark Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { /* <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; // ... // Pass the selected object to the new view controller. [self.navigationController pushViewController:detailViewController animated:YES]; [detailViewController release]; */ } #pragma mark - #pragma mark Memory management - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Relinquish ownership any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. // For example: self.myOutlet = nil; /* I added these two lines */ self.uiView = nil; self.uiTableView = nil; } - (void)dealloc { /* I added these two lines */ [uiView release]; [uiTableView release]; [super dealloc]; } @end
这意味着RootViewController的view
属性(从UIViewController
inheritance)没有连接到nib文件中的视图。 如果右键单击对象图中的文件所有者,那么您会看到它的view
插件连接到布局中的视图,如附加的截图所示。
你可以发布你的RootViewController.h文件作为编辑你的问题?
您只需要将xib中的默认视图连接到文件所有者。