2010-12-04 57 views
0

ViewController.mUITableView的錯誤

#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: (
+1

您的帖子很難閱讀代碼。 – AechoLiu 2010-12-04 04:21:00

回答

0

即使世界沒有錯代碼。可能還有其他一些潛在問題,可能是XIB。你確定highScoreTable已連接?

+0

雅表已連接。因此我拒絕了什麼是錯誤。 – lol 2010-12-04 04:53:48

0

可以檢查數據源和UITableView中的代表- (無效)viewDidLoad中? 從nib加載後它們不應該爲零。

0

hai FYI你是否正確地分配tableView?請檢查出

示例highScoreTable = [[UITableView alloc]init];