我的iphone应用程序中有一个动作表弹出窗口.我想用数组中的字符串填充它而不是预定值.
我在网上找不到任何东西来做这件事!也许动作表不适合使用?
现在这是我用它来构建它:
roomspopup = [ [ UIActionSheet alloc ]
initWithTitle: alertname
delegate: self
cancelButtonTitle: @"Cancel"
destructiveButtonTitle: nil
otherButtonTitles: @"Kitchen", "Dining Room", nil ];
Run Code Online (Sandbox Code Playgroud)
但是,我不想用"厨房"和"餐厅"来填充数组.阵列的大小(即房间数)不是固定的数字.
Dir*_*sch 14
@JimTrell
解决这个问题的方法是在没有取消按钮的情况下初始化UIActionSheet,并在添加其他按钮后添加此取消按钮.
首先使用一堆nil来初始化工作表:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
Run Code Online (Sandbox Code Playgroud)
然后循环遍历您的数组,addButtonWithTitle:最后添加取消按钮并设置其索引:
[actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet setCancelButtonIndex:[yourArray count]];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2214 次 |
| 最近记录: |