UIActionSheet添加多个otherButtonTitles

来源:互联网 发布:模拟炒股大赛 知乎 编辑:程序博客网 时间:2024/06/06 03:35

关于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];

大功告成
1 0