Reputation: 1219
I am developing an app that requires me to drag a colored box that is a UIImageView on top of a row of a UITableView. When I release the colored box on a specific row, I want to change the color of that row to the color of the box. Currently I am able to drag and drop the box but I'm facing problem in getting the row index of the row on which I release touch. The image attached depicts what I want to do. I have dragged the red box on the blue row, and I want to change the color of the row from blue to red. But I cant figure out a way to get the row index on which I drop the box.
Upvotes: 0
Views: 150
Reputation: 14477
You can get tableView cell by getting indexPath at rootPoint, like this.
CGPoint touchPoint = [[touches anyObject] locationInView:self.tableView];
CGPoint cellPoint= [sender.superview convertPoint:touchPoint toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:cellPoint];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
Upvotes: 1