2012-09-04 42 views
1

如何添加文本到我的字幕?目前我有一個名爲列表的NSArray,如何爲名稱添加字幕?如何將字幕添加到Xcode中的tableview中

lodgeList = [[NSArray alloc]initWithObjects: 

      @"Abingdon Lodge No. 48", 
      @"York Lodge No. 12", 
      @"Alberene Lodge No. 277", 

      nil]; 

繼續...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

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


cell.textLabel.text =[lodgeList objectAtIndex:indexPath.row]; 

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

return cell; 
+0

小小的幫助將會很好......不只是-1我的問題 – Appsicode

+1

我猜想否定的選票是由於問題的模糊性。也許顯示你已經有的代碼,並且更全面地解釋你想要達到的目標,可能會幫助你獲得更好的迴應。正如所寫的那樣,確實無法分辨出問題所在 - 無論是在tableview設置還是數據本身。 –

+0

我剛剛更新了代碼示例的問題。對不起,關於 – Appsicode

回答

2

假設你使用的是標準的UITableViewCell,請確保您的表格單元格的樣式設置爲UITableViewCellStyleSubtitle,然後通過設置單元的detailTextLabel.text屬性設置字幕文本。

+0

感謝VeryVito,我需要爲字幕創建另一個NSArray?或者只是創建屬性並添加「subtitle.detailTextLable.text = [subtitle ..... – Appsicode

+0

請參閱上面的我的評論。有很多方法可以完成(通過單獨的字符串數組,例如,或單個數組包含各種字符串作爲鍵控對象的字典等等,不知道你已經得到了什麼。) –

+0

這是否有幫助?我想添加子視圖到小屋名稱。 – Appsicode

相關問題