我試圖創建一個導航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