回答
答:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//Now you can use cell.textLabel.text to get the title text of the selected static cell and assign it to your Property.
NSString *yourStr = cell.textLabel.text;
}
yepp我剛剛發現了這個。非常感謝。 – BluGeni 2013-05-10 14:27:05
你並不需要檢查每個indexPath的價值。嘗試是這樣的:
cell.titleLabel.text = [NSString stringWithFormat: @"World %d", indexPath.row];
不完全是我正在尋找標題是不同的單詞不只是一個數字的變化。 – BluGeni 2013-05-10 14:16:57
1)定義了一個NSArray的財產,
@property(nonatomic, strong) NSArray *titlesArray;
2)添加標題到陣列,
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.titlesArray = [[NSArray alloc] initWithObjects:@"Title 1",@"Title 2",@"Title 3",@"Title 4",@"Title 5",@"Title 6",@"Title 7", nil];
}
3)使用他們這個樣子,
- (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];
}
cell.textLabel.text = [self.titlesArray objectAtIndex:[indexPath row]];
return cell;
}
現在,當表格加載時,我有空白單元格。 – BluGeni 2013-05-10 14:16:25
你設置表格視圖以自我的委託和數據源? – 2013-05-10 14:24:29
- 1. 選中單元格時更改標籤屬性
- 2. 如何從選定的tableview單元格獲取標題部分標題?
- 3. Zend表單元素標籤「爲」屬性
- 4. 組織django-tagging標籤或爲標籤分配屬性?
- 5. 表格中特定單元格的行標題和列標題
- 6. 將高度屬性分配給選項標籤
- 7. 自定義單元格標籤
- 8. 刪除選擇標籤中第一個選定元素的選定屬性?
- 9. 獲取選定標籤的標題
- 10. 表格單元格中的標籤
- 11. jQuery - 選擇標籤 - 獲取所選元素的屬性
- 12. 標籤與元素(無標籤)和Android的屬性使用簡單的XML
- 13. 元素中的屬性關閉標籤?
- 14. ASP.NET Core中的單元測試標籤助手 - 填充標籤公共屬性
- 15. 自定義單元格標籤只顯示行選擇
- 16. 轉換多個標籤XML到單個標籤的屬性
- 17. 選擇使用標籤和屬性選擇元素角JS
- 18. jquery選擇html表格單元格內的所有標籤
- 19. JSP標籤屬性
- 20. 標籤屬性爲
- 21. 標籤屬性length
- 22. 選擇Handsontable標題單元
- 23. 屬性更改標籤顏色標籤
- 24. eval和錨定標籤href中的文本標籤屬性ASP.Net
- 25. 在WPF中分配控件的標籤屬性
- 26. 巨大的HTML表格,帶有固定標題,標題單元格和行單元格之間的對齊
- 27. WPF:綁定標籤的類屬性
- 28. HTML/CSS標籤:考慮其他標籤屬性的標籤
- 29. 將單元格分配給3乘3網格中的座標
- 30. WinForms Datagridview:標籤屬性問題
你能解釋一下你想要什麼? – Bhavin 2013-05-10 14:04:49
我想選擇的靜態單元格的標題文本分配給屬性 – BluGeni 2013-05-10 14:20:44
我發現正是我一直在尋找最終 http://stackoverflow.com/questions/4444312/how-to-get-title-行選擇在適當的視圖 – BluGeni 2013-05-10 14:26:09