2011-03-24 67 views
3

我试图创建一个导航stype应用程序,但我想自定义初始视图,以便tableview不占用整个框架,而是嵌入在一个子视图中,所以我可以应用程序首次启动时的一些标签和图像。RootViewController上的NSInternalInconsistencyException

我宣称UIViewUITableView ivars在RootViewController.h,并添加它们作为属性与标准的“(nonatomic, retain) IBOutlet”标记;并在RootViewController.m,我合成了两个,并添加代码将它们设置为nilviewDidUnload,并在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 
+0

我把你的答案合并到你的问题中,你可能想编辑前言。请不要回复作为答复,并考虑采取社区给你的建议:) – 2011-03-24 14:14:28

+0

我发布了回复作为答案,因为我无法发布回复。我得到的建议是什么?我已经检查并重新检查了nib文件,并且所有属性都连接到文件的所有者。那么解决这个问题的下一步是什么? – Namhcir 2011-03-24 16:06:05

回答

1

这意味着,该RootViewController的的view属性(从UIViewController继承)没有连接到笔尖文件的视图。如果右键单击对象图中的文件所有者,那么您会看到它的view插座连接到布局中的视图,如附加的截图所示。

the file's owner's view property connected to a view

您可以发布您RootViewController.h文件作为编辑你的问题?

+0

是的,我看到连接如下: – Namhcir 2011-03-24 12:30:45

+0

如下? :-) – CharlieMezak 2011-03-24 12:32:21

+0

文件的所有者具有为我的实例变量属性以及视图属性列出的插座; (对不起,我似乎无法按照您的方式剪切和粘贴图像)... – Namhcir 2011-03-24 12:35:57

0

您只需将xib中的默认视图连接到文件所有者即可。

+0

当我在RootViewController.xib文件中查看文件的所有者时,插座的圆圈填充在 – Namhcir 2011-03-24 12:38:00

+0

看视图是否连接,如果已连接,则断开连接并重新连接 – saadnib 2011-03-25 04:26:59

相关问题