2013-07-24 46 views
0

我有一個視圖控制器內的UITableView。非常奇怪,因爲標題顯示出來,而標題文本卻沒有顯示單元格文本。單元格文本沒有打開 - UITableView

- (void)viewDidLoad 
{ 

table.delegate = self; 
selection= [[NSMutableArray alloc] init]; 

[selection addObject:@"text"]; 
[selection addObject:@"text"]; 
[selection addObject:@"text"]; 
...} 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
// configure the cell in each row 

static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease]; 
} 
NSString *cellValue = [selection objectAtIndex:indexPath.row]; 
cell.textLabel.text = cellValue; 
// cell.textColor=[UIColor blackColor]; 
    return cell; 
} 

回答

1

嘗試加入這一行

table.dataSource = self; 

這樣一來,所有的表視圖數據源的方法(包括的cellForRowAtIndexPath :)是所謂的,只要你的類符合UITableViewDataSource協議。

相關問題