2010-12-04 4 views
0

ViewController.merreur UITableView

#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; 

Erreur:

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

Votre message est difficile à lire les codes. – AechoLiu

Répondre

0

Il n'y a rien de mal à ce code. Il peut y avoir quelques autres problèmes sous-jacents, peut-être dans un XIB. Etes-vous sûr (e) que le highScoreTable est connecté?

+0

la table est connectée. donc je ne sais pas quelle est l'erreur. – lol

+0

Si vous n'avez aucune autre vue dans ce contrôleur, je suggère de changer UIViewController en UITableViewController. – WrightsCS

0

Pouvez-vous vérifier la dataSource et délégué de UITableView dans - (void) viewDidLoad? Ils ne devraient pas être nuls après chargement de la plume.

0

hai FYI êtes-vous allouer la tableView correctement? vérifier s'il vous plaît

exemple highScoreTable = [[UITableView alloc]init];