首页 > 代码库 > UIActionSheet添加多个otherButtonTitles

UIActionSheet添加多个otherButtonTitles

关于UIActionSheet,我们经常用到的就是

UIActionSheet *actionSheet = [[UIActionSheetalloc]initWithTitle:@"请选择"delegate:selfcancelButtonTitle:@"取消"destructiveButtonTitle:@"确定"otherButtonTitles:@"1",@"2",@"3",nil];

但是当otherButtonTitles要显示一个数组的时候并不是用

[AryobjectAtIndex:i]

如果这样用的话就会出错,就算不出错,也会pop[Ary count]次

所以,可以这样

 UIActionSheet *actionSheet = [[UIActionSheetalloc]initWithTitle:@"请选择"delegate:selfcancelButtonTitle:@"取消"destructiveButtonTitle:@"确定"otherButtonTitles:nil];

 //

   for(int j=0;j<[allArycount];j++)

    {

       NSString *str=[[NSStringalloc]initWithFormat:@"%@",[allAryobjectAtIndex:j]];

        [actionSheetaddButtonWithTitle:str];

                       

    }

    [actionSheetshowInView:self.view];

大功告成