2010-12-19 4 views
4

iOS 4.2에서 UIActionSheet를 사용하여 일부 동작이 변경되었습니다. 애플의 개발자 문서 나 포럼에서 아무것도 찾을 수 없으므로 어떻게 해결해야할지 모르겠다.UIActionSheet 긴 목록 동작이 4.2에서 변경 되었습니까?

내 목록 앱에서 시작시로드 할 목록을 선택할 수있는 작업 시트를 사용자에게 제공합니다. 분명히 그것은 가변 수의 항목이있을 것이며 컨트롤이 잘 처리한다는 것을 의미합니다. 약 7 항목까지, 모든 항목을 버튼으로 표시합니다. 일단이 임계 값을 넘으면 항목을 스크롤보기에 넣어 선택합니다. 4.2까지는 스크롤 목록에 취소 버튼이 포함되었습니다. 4.2에서는 Cancel 컨트롤을 분리하여 나머지 항목을 스크롤 뷰에 넣는 동안 버튼으로 남겨 두는 것 같습니다. 문제는 단추 인덱스 목록에 Cancel 항목을 유지하는 것으로 보이므로 buttonTitleAtIndex : buttonIndex를 clickedButtonAtIndex : 또는 didDismissWithButtonIndex :에서 검사 할 때 첫 번째 항목은 "Cancel"을 반환하고 다른 항목 제목은 취소 단추를 클릭하면 "취소"가 반환됩니다.

다른 누구나이 경험이 있으며 처리 방법에 대한 제안이 있으십니까? 다시 말하지만 3.0, 3.1, 4.0 및 4.1에서 정상적으로 작동합니다.

- (IBAction)popupDefaultListActionSheet { 
    UIActionSheet *popup = [[UIActionSheet alloc] 
     initWithTitle:nil 
     delegate:self 
     cancelButtonTitle:@"Cancel" 
     destructiveButtonTitle:nil 
     otherButtonTitles:nil]; 
    for (List *l in allActiveLists) { // allActiveLists defined elsewhere 
    [popup addButtonWithTitle:[l label]]; 
    } 
    popup.actionSheetStyle = UIActionSheetStyleBlackOpaque; 
    popup.tag = 23; 
    [popup becomeFirstResponder]; 
    [popup showInView:[self.view.window.subviews objectAtIndex:0]]; 
    [popup release]; 
} 

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

    DLOG(@"AppSettingsVC.actionSheet didDismissWithButtonIndex: %d", buttonIndex); 
    NSString *defaultListName = [actionSheet buttonTitleAtIndex:buttonIndex]; 
    DLOG(@"chosen default list was: %@", defaultListName); 
} 
+0

언급하는 것을 잊어 버렸습니다. 다른 ButtonTitles가 줄에 제공되면 괜찮아 보입니다. 따라서 addButtonWithTitle :이 작동하는 방식과 일치해야합니다. –

답변

3

시도가 처음 그것을 설정하는 대신 마지막에 동적으로 취소 버튼을 추가 :

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"My Action Sheet" 
                 delegate:self 
               cancelButtonTitle:nil 
              destructiveButtonTitle:nil 
               otherButtonTitles:nil]; 

for (I32 i = 0; i < itemCount; i++) { 
    [actionSheet addButtonWithTitle:itemText]; 
} 

[actionSheet addButtonWithTitle:@"Cancel"]; 
[actionSheet setCancelButtonIndex:itemCount]; 

는 아이폰 OS 4.2에서 제대로 작동하는 것 같다

여기 내가 사용 관련 코드입니다 적어도 우리를 위해.

+0

고마워, 그랬어! 4.2 버튼이 동적으로 버튼을 추가하기 위해 모든 것을 원한다고 생각합니까? –

관련 문제