2009-04-20 36 views
0

在我的應用程序中,我希望某些按鈕在我的表格視圖中沒有選定行時處於非活動狀態。有一個方法didSelectRowAtIndexPath,告訴我何時選中了一行。有沒有辦法知道一行是否被取消選擇?UITableView - 如何識別取消選擇?

預先感謝您。

回答

2

UITableView中有一種稱爲deselectRowAtIndexPath:animated:的方法。 您必須在自定義類中覆蓋它以對取消選擇做出反應。

看到這個article

0
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
    if (thisCell.accessoryType == UITableViewCellAccessoryNone) { 
     thisCell.accessoryType = UITableViewCellAccessoryCheckmark; 
     cout << "selected Row: " << selectedRow << endl; 
    } else { 
     thisCell.accessoryType = UITableViewCellAccessoryNone; 
     cout << "deselected Row: " << selectedRow << endl; 

    } 
} 

是一種可視化和編程方式顯示它的方法。

相關問題