을 받고, IOS 테이블보기를 사용하려고하지만, 내가 응용 프로그램을 실행할 수 없습니다, 나는 런타임에이 오류가 발생합니다 :내가 응용 프로그램 탭 내 아이폰 OS의 테이블보기가 오류
3/23/12 10:15:23.119 PM CodeCompanion: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "2-view-16" nib but didn't get a UITableView.'
*** First throw call stack:
(0x13bd052 0x154ed0a 0x1365a78 0x13659e9 0x2436ae 0xda5cb 0xf5b89 0xf59bd 0xf3f8a 0xf3e2f 0xf1ffb 0xf285a 0xdbfbf 0xdc21b 0xdd0f1 0x4bfec 0x51572 0x4b72b 0x3abc2 0x3ace2 0x3aea8 0x41d9a 0x12be6 0x138a6 0x22743 0x231f8 0x16aa9 0x12a7fa9 0x13911c5 0x12f6022 0x12f490a 0x12f3db4 0x12f3ccb 0x132a7 0x14a9b 0x2888 0x27e5)
내보기 컨트롤러
#import <UIKit/UIKit.h>
@class LanguageTableViewCell;
@interface LanguagesViewController : UITableViewController {
NSArray *languages;
}
@property (nonatomic, retain) NSArray *languages;
@end
내 구현 파일은 다음과 같습니다 : 헤더 파일은 다음과 같습니다
#import "LanguagesViewController.h"
#import "LanguageTableViewCell.h"
@implementation LanguagesViewController
@synthesize languages;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"getting cell for row at index path: %i", [indexPath row]);
LanguageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"languageBase"];
if (cell == nil) {
cell = [[LanguageTableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"languageBase"];
}
[cell setName:[languages objectAtIndex:[indexPath row]]];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"rows in section: %i is: %i", section, [languages count]);
return [languages count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
NSLog(@"getting number of sections (1)");
return 1;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"view loaded, setting array");
languages = [NSArray arrayWithObjects:@"Java", nil];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
@end
내가 엑스 코드와 objective-에 아주 새로운 해요 c, 잘못되었을 수있는 것을 언급하십시오. 테이블 뷰의 ViewController를 위의 클래스에 설정했는데 xcode에 오류나 경고가 표시되지 않습니다. 테이블 뷰는 프로토 타입 셀을 사용하는 동적 뷰 중 하나입니다. 세포의 클래스를 게시해야한다면, 그렇게 할 것입니다.
슈퍼 클래스를 UITableViewController에서 UIViewController로 변경하십시오. – CodaFi