溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

IOS 開發(fā)之實現(xiàn)取消tableView返回時cell選中的問題

發(fā)布時間:2020-09-07 16:35:26 來源:腳本之家 閱讀:128 作者:wy_19921005 欄目:移動開發(fā)

IOS 開發(fā)之實現(xiàn)取消tableView返回時cell選中的問題

在對表格UITableView操作時,有時當用戶選中表格行后,需要自動取消選擇。實現(xiàn)這種效果,其原理是選中表格行時,會調(diào)用 didSelectRowAtIndexPath方法,只要在這個方法中,調(diào)用performSelector執(zhí)行取消選中表格行的方法。

示例代碼如下: 

- (void) unselectCurrentRow
{

 // Animate the deselection

 [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
}

 

- (void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)newIndexPath
{

 // Any other table management you need

 ...

 

 // After one second, unselect the current row

 [self performSelector:@selector(unselectCurrentRow)withObject:nil afterDelay:1.0];

} 

在performSelector中還可以設(shè)定延遲時間。unselectCurrentRow方法中則完成取消表格行的選擇,并且實現(xiàn)了動畫效果。

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI