2013-01-18 36 views
0

enter image description here在iPhone SDK

特別的TableView正如你看到的上面,我有萊夫特賽德表視圖其中包含一些文本。

但是,當我選擇任何註解在地圖根據該單元格將被突出顯示&它有更多的文本,而不是其他單元格,並且背景顏色也改變。

我該如何做到這一點?

回答

1
  1. 您需要定製UITableViewCell
  2. 添加表格視圖,如圖所示在你查看地圖查看。
  3. 負載定製表視圖細胞泰伯維
  4. 最初得到所需顏色的所有表格單元
  5. 當用戶選擇一個小區改變它的顏色
  6. 使用didSelectRowAtIndexPath:委託方法在地圖上顯示對應的值。

檢查此鏈接教程:

+0

感謝您的回覆..我可以使用不同的自定義'UITableViewCell'&當我選擇任何註釋,根據該單元格將被選中。 – user1673099

+0

@ user1673099:當您選擇註釋時,請使用'selectRowAtindexPath'選項來選擇單元格 –

+0

,但是鋤頭可以在選擇它時調整tableview單元格的大小。 – user1673099

0

我認爲你正在創建自定義註釋而不是默認的註釋,所以如果你可以爲每個註釋視圖設置標記,這將與tableview單元格索引相同。在選擇註釋時,使用該標記創建indexpath併爲該indexpath設置selectedrow。希望它可以幫助你。

2

您可以通過以下方式進行操作。
首先,Map中的表格數據和註釋引腳都是從數組中填充的! 你可以做什麼,你可以定義「標籤」作爲特定項目的數組索引。 當用戶點擊註釋時,該註釋具有「標籤」(或數組索引),並且該「標籤」(或數組索引)也具有用於表格數據的項目。 單擊註釋點擊,您必須重新加載您的表格並使該特定的tableview單元格突出顯示。

+0

但是,如何在選擇和取消選擇時調整單元格的大小。 – user1673099

+1

使用 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;委託方法。 返回浮點值以更改行的大小 – Anil

0
  1. 創建您自定義的課程UITableViewCell
  2. 瞭解你有兩個條件A.正常細胞B.點擊後的細胞。

你將不得不使用UITableView的3個委託方法來實現這一點。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Here you'll have to check for the condition you'll have to check which indexPath.row is selected. and according to that you'll have to change the height of your row. 
    return hight; 

} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Again the same thing. You'll have to check the condition and load the appropriate controls with appropriate frames. 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // This is the important function for you. 
    // Here you'll have to set one counter. Which you'll use in the 
    // After that reload the table. 
}