Cocoa touch 将值从UIButton传递到UIActionSheet

Cocoa touch 将值从UIButton传递到UIActionSheet,cocoa-touch,uikit,uibutton,uiactionsheet,Cocoa Touch,Uikit,Uibutton,Uiactionsheet,我正在尝试从按钮发送一个操作表变量 我无法使用tag属性,因为它正在用于其他内容 我已将myIndexRow声明为实例变量,并具有: NSInteger myIndexRow = indexPath.row; [deleteButton addTarget:self action:@selector(showDeleteSheet:) forControlEvents:UIControlEventTouchUpInside]; deleteButton.myIndexRow =

我正在尝试从按钮发送一个操作表变量

我无法使用tag属性,因为它正在用于其他内容

我已将myIndexRow声明为实例变量,并具有:

NSInteger myIndexRow = indexPath.row;
    [deleteButton addTarget:self action:@selector(showDeleteSheet:) forControlEvents:UIControlEventTouchUpInside];

    deleteButton.myIndexRow = myIndexRow;
但我得到的是“对成员‘myRow’的请求不是一个结构或联盟”


很明显,我在这里遗漏了一些东西。

我从来没有想过我会回答自己的问题,所以,下面是:

访问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的ClickedButtonIndex方法中,我得到了我需要的行:

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

     if (buttonIndex == 0)
        { ... doSomethingWith: actionSheet.tag }
     else
        { ... user pressed cancel }
}

部分答案已找到,其余的

上述答案均失败。请参阅下面的答案以了解执行此操作的方法。