UITableViewDelegate
有一個方法來確定我在tableView
中選擇哪一行。如何計算我在桌面視圖中選擇特定行的時間數
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
但我怎麼知道哪一行我選擇了多少次?
UITableViewDelegate
有一個方法來確定我在tableView
中選擇哪一行。如何計算我在桌面視圖中選擇特定行的時間數
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
但我怎麼知道哪一行我選擇了多少次?
在你的datamodel
中,你可以有一個int變量來知道數據被選擇了多少次。增加你在問題中提到的方法。我希望你現在明白這個主意。重複使用時,您不能使用該單元來保持計數。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
獲取數據和indexpath.row並增加計數。
只需在didSelectRowAtIndexPath:
中創建一個整數int count
並在您選擇該行時將count
增加1。簡單的邏輯。
它不會工作,因爲問題是要獲得每行的數量而不是整體。 –
然後您可以選擇標記每一行。 – iOS
好,因爲單元格被重用,單元格上的標籤將覆蓋prev值。 –