2009-12-11 47 views
36

我一直在google搜索,試圖找出當UITableView中的一行(或單元格)被點擊時調用了什麼類型的事件句柄,但一直未能弄清楚。我試圖在點擊時更改單元格的圖像屬性。UITableView/UITableViewCell點擊事件響應?

謝謝。

回答

94

當表格行被點擊時,有兩種可能的事件:選擇行和附件視圖(通常是「更多細節」類型的動作)。

只要您已經註冊了的UITableView的委託,下面就可以實現,並且將在觸摸叫:

// Tap on table Row 
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { ... } 

// Tap on row accessory 
- (void) tableView: (UITableView *) tableView accessoryButtonTappedForRowWithIndexPath: (NSIndexPath *) indexPath{ ... }