Skip to content

Instantly share code, notes, and snippets.

@tony0x59
Created April 28, 2014 07:54
Show Gist options
  • Save tony0x59/11364735 to your computer and use it in GitHub Desktop.
Save tony0x59/11364735 to your computer and use it in GitHub Desktop.
用于替代DirtyHack([[sender superview] superview])
#import "UITableView+CellForPressedButton.h"
@implementation UITableView (CellForPressedButton)
- (NSIndexPath*)indexPathForPressedButton:(UIView*)button
{
CGPoint buttonPosition = [button convertPoint:CGPointZero toView:self];
NSIndexPath *indexPath = [self indexPathForRowAtPoint:buttonPosition];
return indexPath;
}
- (id)cellForPressedButton:(UIView*)button
{
NSIndexPath *indexPath = [self indexPathForPressedButton:button];
UITableViewCell *cell = [self cellForRowAtIndexPath:indexPath];
return cell;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment