ViewController.m
#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;
}
ViewController.h
@interface PSLEViewController : UIViewController <UITableViewDelegate,UITableViewDataSource>
{
IBOutlet UITableView *highScoreTable;
}
@property(retain,nonatomic) UITableView *highScoreTable;
错误:
2010-12-04 02:20:15.541 PSLE[14369:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[PSLEViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x3b13080'
2010-12-04 02:20:15.542 PSLE[14369:207] Stack: (
答案 0 :(得分:0)
该代码没有任何问题。可能存在一些其他潜在问题,可能在XIB
中。您确定highScoreTable
已连接吗?
答案 1 :(得分:0)
您可以在 - (void)viewDidLoad 中查看UITableView的 dataSource 和委托吗? 从笔尖加载后它们不应该是零。
答案 2 :(得分:0)
hai FYI你正确分配tableView吗?请查看
示例highScoreTable = [[UITableView alloc]init];