alekseyn / EasyTableView

Horizontal and vertical scrolling table views for iOS
BSD 3-Clause "New" or "Revised" License
584 stars 157 forks source link

Question: Control touch on selected cell #4

Closed sanemat closed 12 years ago

sanemat commented 13 years ago

Hi, I want to control touch event on selected cell. I try to custom EasyTableView, but I failed. Please give me any advice.

my try: l208-l211 comment out : failed

//  // Don't allow the currently selected cell to be selectable
//  if ([_selectedIndexPath isEqual:indexPath]) {
//      return nil;
//  }
alekseyn commented 13 years ago

Selecting cells in table views are handled automatically for you by UITableView (andEasyTableView). The code you commented out is simply to prevent a user from selecting a selected cell more than once. However, I tried commenting out the same code and everything works fine. That is because setSelectedIndexPath: includes another check against _selectedIndexPath. This check is required for the logic within setSelectedIndexPath to be valid. Have you tried simply using EasyTableView's delegate method easyTableView:selectedView:atIndex:deselectedView:?

sanemat commented 13 years ago

I use EasyTableView's delegate method "easyTableView:selectedView:atIndex:deselectedView:". I did not catch "index" in * selected * cell. I want to detect touch event on selected cell "more than once".

thiagoperes commented 13 years ago

Go to EasyTableView.m and...

In - (void)setSelectedIndexPath:(NSIndexPath *)indexPath, remove the following condition: if ([_selectedIndexPath isEqual:indexPath]) and keep the block

In - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath remove the condition if ([_selectedIndexPath isEqual:indexPath]) and the block (return nil;)

Hope this helps!