【发布时间】:2014-08-14 10:19:17
【问题描述】:
我将一个数组(来自数据库)传递给操作表。我添加了取消按钮,但它没有取消。它显示错误数组超出范围。这是我的代码:
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Chatting Apps" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil];
for (int i =0;i<self.arrOfAppNames.count;i++) {
[actionSheet addButtonWithTitle:[[self.arrOfAppNames objectAtIndex:i]objectAtIndex:1]];
}
[actionSheet addButtonWithTitle:@"Cancel"];
actionSheet.cancelButtonIndex = [self.arrOfAppNames count];
[actionSheet showInView:self.view];
【问题讨论】:
-
只需从
[actionSheet addButtonWithTitle:[[self.arrOfAppNames objectAtIndex:i]objectAtIndex:1]];行中删除objectAtIndex:1 -
@SweetAngel 你是对的,这是这个问题的解决方案。你必须把它作为你的答案。如果你想放,我会删除我的答案
-
谢谢... :) @MohitPopat
标签: ios objective-c uiactionsheet uiactionsheetdelegate