[英]How to catch event of pressing TableViewCell?
我有問題...我有UITableView,我想在用戶按下單元格時捕獲事件,以便更改我插入UITableViewCell的標簽顏色。 用戶觸摸單元格的那一刻。
功能對我沒有幫助......
誰有任何建議? 非常感謝你的幫助!
對UITableViewCell進行子類化並使用以下方法覆蓋UIResponder:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
然后,當按下和釋放時,您將有2個獨立的事件。
如果要在UITableViewCell
選中時更改UILabel
內部的顏色,則不必執行任何類型的事件捕獲。 您只需要更改UILabel
的highlightedTextColor
屬性。 默認值通常為白色。
你設置了tableView的委托嗎?
您的類是否符合UITableViewDelegate協議?
使用UITableViewDelegate
協議確認並實現您提到的方法,
不要忘記設置UITableView
的委托屬性。
myTableView.delegate = self;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.