我试图创建一个导航stype应用程序,但我想自定义初始视图,以便tableview不占用整个框架,而是嵌入在一个子视图中,所以我可以应用程序首次启动时的一些标签和图像。RootViewController上的NSInternalInconsistencyException
我宣称UIView
和UITableView
ivars在RootViewController.h
,并添加它们作为属性与标准的“(nonatomic, retain) IBOutlet
”标记;并在RootViewController.m
,我合成了两个,并添加代码将它们设置为nil
在viewDidUnload
,并在dealloc
发布它们。 (努力成为一名优秀的记忆管理公民。)我没有添加任何其他代码。编译时没有警告。当我试图试驾应用程序,它与消息立即(和重复)坠毁:
*** Terminating app due to uncaught exception
NSInternalInconsistencyException',
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the
"RootViewController" nib but the view outlet was not set.'
我已经连接两者的观点和我的RootViewController
笔尖的tableview到文件的所有者;当我右键单击对象图中的文件所有者时,我将它们都列为Outlet。当我右键单击每个控件时,我将文件所有者视为引用出口。
帮助!我该如何解决?
更新
//
// 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
我把你的答案合并到你的问题中,你可能想编辑前言。请不要回复作为答复,并考虑采取社区给你的建议:) – 2011-03-24 14:14:28
我发布了回复作为答案,因为我无法发布回复。我得到的建议是什么?我已经检查并重新检查了nib文件,并且所有属性都连接到文件的所有者。那么解决这个问题的下一步是什么? – Namhcir 2011-03-24 16:06:05