从来没想过我会回答我自己的问题,但下面是:
访问superview的superview并查询indexpath部分和行属性就是其中的关键。
在按钮的目标中:
-(void)showDeleteSheet:(id)sender {
NSIndexPath *indexPath = [table indexPathForCell:(UITableViewCell *)[[sender superview] superview]];
NSInteger currentSection = indexPath.section;
NSInteger currentIndexRow = indexPath.row;
//form the actionSheet
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Delete this item?"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Delete"
otherButtonTitles:nil];
actionSheet.tag = currentIndexRow;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
[actionSheet release];
}
然后在ActionSheet的ClickedButtonatindex方法中,我得到了我需要的行:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{ ... doSomethingWith: actionSheet.tag }
else
{ ... user pressed cancel }
}
找到了部分答案
in another post and
其余的
here