Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 动态UIActionSheet';其他按钮:和#x27;_Ios_Twitter_Uiactionsheet_Acaccount - Fatal编程技术网

Ios 动态UIActionSheet';其他按钮:和#x27;

Ios 动态UIActionSheet';其他按钮:和#x27;,ios,twitter,uiactionsheet,acaccount,Ios,Twitter,Uiactionsheet,Acaccount,我正在尝试创建一些东西,以便在UIActionSheet中列出用户连接到设备的所有Twitter帐户。例如,我的设备上有三个Twitter帐户。我想在行动表上用“取消”按钮列出我的帐户。目前,我的函数如下所示: - (void)showAlertViewForAccounts:(NSArray*)accounts { accounts = _.arrayMap(accounts, ^id(ACAccount *account) { return account.usern

我正在尝试创建一些东西,以便在
UIActionSheet
中列出用户连接到设备的所有Twitter帐户。例如,我的设备上有三个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]];
}
我的问题是取消按钮没有显示在行动表的单独“部分”


我是否可以A.)将
账户
数组转换为
va_列表
,作为
ui操作表
init…
方法的参数传入,或B.)指定取消按钮应显示在单独的“部分”中?

在其他按钮之后添加取消按钮:

- (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]];
}

令人惊叹的。谢谢你的快速回复@JoeBlow-最好用这么多代码发布你自己的答案,而不是把它全部添加到我的答案中。