2011-04-11 73 views
1

當你在屏幕上看到打印,總的tableView顯示TableView中「標題」一個單一的值我的問題是,以顯示所有的數組值detailTableView問題顯示在的tableView

- (void)viewDidLoad { 

NSArray* tmpArray = [[NSArray alloc] initWithObjects:@"Titre", @"Nom", @"Prenon",@"Adresse",@"Phone",@"Mobile",@"Mail",@"Site",@"Note",nil]; 
self.detailsTableView = tmpArray; 
[tmpArray release]; 

[super viewDidLoad]; 

}


- (UITableViewCell *)tableView:(UITableView *)atableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
} 

// Configure the cell... 

cell.textLabel.text =[self.detailsTableView objectAtIndex:indexPath.row] ;  
return cell; 

} enter image description here

+0

嘗試將cell.textLabel.text放入if子句中。另外,請嘗試使cellIdentifier獨一無二。 – 2011-04-11 10:01:08

回答

3

從屏幕抓取,它看起來像你只得到了每部分一個細胞。在這種情況下,您需要使用indexPath.section而不是indexPath.row。

+1

+1良好的觀察... – Jhaliya 2011-04-11 10:13:53

1

從蘋果文檔

爲textLabel

返回用於表格單元格的主要文字內容的標籤。 (只讀)

@property(nonatomic, readonly, retain) UILabel *textLabel 

討論

承裝電池的主要標籤。當您以給定單元格樣式創建單元格時,UITableViewCell 會添加適當的標籤。有關當前定義的單元格樣式中主標籤的說明,請參見「單元格樣式」。

因此,創建一個新的UILabel並將其添加到textLabel

0

你設置如下:

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section { 

return [self.detailsTableView count]; 
}