2010-04-19 2 views
0

버튼에서 변수를 ActionSheet로 보내려고합니다.UIButton에서 UIActionSheet로 값을 전달하는 중

태그 속성은 다른 용도로 사용되기 때문에 사용할 수 없습니다. 내가 인스턴스 변수로 myIndexRow을 선언 한

가 있습니다

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

    deleteButton.myIndexRow = myIndexRow; 

하지만 myRow '회원 요청'을 받고 있어요는

가있다 '뭔가 아닌 구조 또는 노동 조합 인' 명백한 무엇인가 나는 여기에서 놓치고있다.

+0

위 항목이 실패했습니다. 이렇게하는 방법은 아래의 답변을 참조하십시오. –

답변

1

내가 SO에 내 자신의 질문에 대답 거라고 생각하지 않습니다 그러나 여기 간다 마십시오 :

수퍼의 수퍼를 액세스 및 indexPath 섹션을 조회 및 행 속성은 트릭을했다. 버튼의 대상에서

:

는 actionSheet의 clickedButtonAtIndex 방법에 내가 행을 얻을 아래
-(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]; 
} 

은 그럼이 필요합니다 대답의

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

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

일부는 in another post and 발견되었고 나머지 here