2011-09-01 75 views
1

我正在製作一個應用程序,我正在使用基於視圖的應用程序。
我的第一個視圖是一個簡單的視圖控制器類。該視圖中有一些按鈕。
當我點擊按鈕,我想要tableview。
所以我採取UITableViewController子類。UITableView不顯示任何數據

我所硬幣

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    NSBundle *bundle =[NSBundle mainBundle]; 
    NSString *path = [bundle pathForResource:@"cases" ofType:@"plist"]; 
    listfile = [[NSArray alloc ] initWithContentsOfFile:path]; 
    [self loadView]; 

} 
- (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... 
NSArray *temp = [listfile objectAtIndex:indexPath.row]; 
cell.textLabel.text = [temp objectAtIndex:0]; 
    NSLog(@"Count : %@" , cell.textLabel.text); 
return cell; 
} 

但是,我看不到任何數據。它只顯示空白表。 我做錯了什麼?

謝謝。

回答

8

你應該實現在您的UITableViewController以下方法:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // Return the number of rows in section. 
    return [caselist count]; 
} 

而且

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return 1; 
} 
+0

哎呀.. !!謝謝Nekto ..我只是忘了設置'return 1' – iUser