关于UIActionSheet,我们经常用到的就是
UIActionSheet *actionSheet = [[UIActionSheet
alloc]initWithTitle:@"请选择"
delegate:self
cancelButtonTitle:@"取消"destructiveButtonTitle:@"确定"
otherButtonTitles:@"1",@"2",@"3",nil];
但是当otherButtonTitles要显示一个数组的时候并不是用
[Ary
objectAtIndex:i]
如果这样用的话就会出错,就算不出错,也会pop[Ary count]次
所以,可以这样
UIActionSheet *actionSheet = [[UIActionSheet
alloc]initWithTitle:@"请选择"
delegate:self
cancelButtonTitle:@"取消"destructiveButtonTitle:@"确定"
otherButtonTitles:nil];
//
for(int j=0;j<[allAry
count];j++)
{
NSString *str=[[NSString
alloc]initWithFormat:@"%@",[allAry
objectAtIndex:j]];
[actionSheet
addButtonWithTitle:str];
}
[actionSheet
showInView:self.view];
大功告成
UIActionSheet添加多个otherButtonTitles,布布扣,bubuko.com
时间: 2024-08-07 21:32:28