4

デバイスに接続されているすべてのユーザーの Twitter アカウントをUIActionSheet. たとえば、私のデバイスには 3 つの Twitter アカウントがあります。アクション シートにキャンセル ボタン付きのアカウントを一覧表示してほしい。現在、私の関数は次のようになっています。

- (void)showAlertViewForAccounts:(NSArray*)accounts {
    accounts = _.arrayMap(accounts, ^id(ACAccount *account) {
        return account.username;
    });

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose an account:"
                                                             delegate:self
                                                    cancelButtonTitle:@"Cancel"
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:nil];
    for (NSString *username in accounts) {
        [actionSheet addButtonWithTitle:username];
    }    


    [actionSheet showInView:[[[[[UIApplication sharedApplication] delegate] window] rootViewController] view]];
}

私の問題は、アクション シートの別の「セクション」にキャンセル ボタンが表示されないことです。

accountsA.)配列を に変換しva_listてメソッドのパラメーターとして渡すUIActionSheet init...か、B.) キャンセル ボタンを別の「セクション」に表示するように指定できますか?

4

1 に答える 1

13

他のボタンの後に [キャンセル] ボタンを追加します。

- (void)showAlertViewForAccounts:(NSArray*)accounts {
    accounts = _.arrayMap(accounts, ^id(ACAccount *account) {
        return account.username;
    });

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose an account:"
                                                             delegate:self
                                                    cancelButtonTitle:nil
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:nil];
    for (NSString *username in accounts) {
        [actionSheet addButtonWithTitle:username];
    }    

    actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:@"Cancel"];  

    [actionSheet showInView:[[[[[UIApplication sharedApplication] delegate] window] rootViewController] view]];
}
于 2014-03-07T02:22:46.023 に答える