2010-05-12 1 views
0

현재 프로젝트에서 두 개의 UIAction 시트를 사용하고 있습니다. 완벽하게 작동하도록 하나 얻을 수 있지만 두 번째 작업 시트를 삽입 할 때 첫 번째 것과 동일한 arguements를 실행합니다. 액션 시트를 어떻게 seperatly 정의합니까?UIActionSheets 도움말에서 작업 만들기

-(IBAction) phoneButtonClicked:(id)sender 
{ 
    // open a dialog with just an OK button 
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                 delegate:self cancelButtonTitle:@"Cancel" 
                 destructiveButtonTitle:nil 
                 otherButtonTitles:[NSString stringWithFormat:@"Phone: %@",phone],nil]; 
    actionSheet.actionSheetStyle = UIActionSheetStyleDefault; 
    [actionSheet showInView:self.view]; // show from our table view (pops up in the middle of the table) 
    [actionSheet release]; 
} 

-(IBAction) mapButtonClicked:(id)sender 
{ 
    // open a dialog with just an OK button 
    UIActionSheet *mapActionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                 delegate:self cancelButtonTitle:@"Cancel" 
                 destructiveButtonTitle:nil 
                 otherButtonTitles:[NSString stringWithFormat:@"Map"],nil]; 
    mapActionSheet.actionSheetStyle = UIActionSheetStyleDefault; 
    [mapActionSheet showInView:self.view]; // show from our table view (pops up in the middle of the table) 
    [mapActionSheet release]; 
} 


-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
     if(buttonIndex == 0){ 
      NSString *callPhone = [NSString stringWithFormat:@"tel:%@",phone]; 
      NSLog(@"Calling: %@", callPhone); 
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]]; 
    } 
} 

답변

0

actionSheets 인스턴스 변수를 만들고 대리자 메서드에서 어떤 조치 시트가 반환되었는지 테스트합니다.

또는 UIActionSheet (및 동일한 불쾌감을 겪는 UIAlert)의 고유 한 하위 클래스를 작성하여 반환 값이 캡처 될 때 위임 객체에 콜백을 보낼 수 있습니다.

3

UIActionSheet은 서브 뷰가 UIView이므로 tag 속성을 사용할 수 있습니다.