自定義單元格,且單元格中有按鈕撒轮,項目功能擴(kuò)展需要點(diǎn)擊按鈕在每一個單元格的后面增加一個視圖乞旦,因此需要確定單元格的indexPath屬性,然后根據(jù)每一個單元格的高度就可以確定每一個單元格的位置题山,因此就可以增加新的視圖兰粉,該問題的關(guān)鍵是點(diǎn)擊按鈕后確定所在單元格的索引,這個時候就要用到一個非常重要的屬性indexPathForRowAtPoint顶瞳。
NSSet *touches = [event allTouches];? //獲取點(diǎn)擊手勢 allTouches方法玖姑,可以獲得觸摸點(diǎn)的集合愕秫,可以判斷多點(diǎn)觸摸事件。
UITouch *touch = [touches anyObject];?
CGPoint currentTouchPosition = [touch locationInView:self.tableView]; 二維坐標(biāo)系中的點(diǎn)
NSIndexPath *indexPaths = [self.tableView indexPathForRowAtPoint:currentTouchPosition];
ChaseOrderTableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPaths];
cellForRowAtIndexPath這個屬性 根據(jù)位置獲取當(dāng)前cell的indexPath
看其他的使用在當(dāng)點(diǎn)擊cell上的Btn的時候 用來增加新的視圖 ?我這里用來用cell傳了一次值焰络。 ?在點(diǎn)擊btn的時候 獲取到當(dāng)前cell的值戴甩。(cell上的值是在請求數(shù)據(jù)的時候聲明了一個屬性)。