Iphone UITableView错误
ViewController.mIphone UITableView错误,iphone,uitableview,Iphone,Uitableview,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 ta
#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;
那代码没有问题。可能还有其他一些潜在问题,可能在XIB中。您确定HighScore表已连接吗?能否在-voidviewDidLoad中检查UITableView的数据源和委托?
从nib加载后,它们不应为零 仅供参考您是否正确分配了tableView?请检查一下
示例highScoreTable=[[UITableView alloc]init] 你的帖子很难读懂密码。你的表是连着的。因此,我不知道是什么错误。如果该控制器中没有任何其他视图,我建议将UIViewController更改为UITableViewController。
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: (