2010-12-19 4 views
4

iOS 4.2でUIActionSheetで動作が変更されています。アップルの開発者向けドキュメントやフォーラムで何かを見つけることができないので、解決方法がわかりません。UIActionSheetロングリストの動作が4.2で変更されましたか?

私のリストのアプリでは、起動時にロードするリストを選択できるアクションシートをユーザーに提示します。明らかに、それはアイテムの可変数があることを意味し、コントロールはそれをうまく処理します。約7項目まで、すべての項目をボタンとして表示します。そのしきい値を超えると、項目をスクロール・ビューに入れて選択します。 4.2までは、そのスクロールリストに[キャンセル]ボタンが含まれていました。 4.2では、キャンセルコントロールを分離して、残りのアイテムをスクロールビューに入れながらボタンとして残しているようです。問題は、buttoneditAtIndex:buttonIndex:didIndex:またはdidDismissWithButtonIndex:を調べると、最初のアイテムが「キャンセル」を返し、他のアイテムのタイトルが「キャンセル」ボタンをクリックすると、「キャンセル」も表示されます。

誰でもこれを体験し、それを処理する方法についての提案がありますか?これも、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]; 

は、iOS 4.2で正しく動作するようですが、少なくとも私たちのために。

+0

ありがとうございました!私は、4.2が、今や、動的にボタンを追加するために全部または何かを望んでいると思いますか? –

関連する問題