Oli*_*lie 20 dynamic button uiactionsheet
我有这个代码:
UIActionSheet *actionSheet = [[[UIActionSheet alloc]
                initWithTitle:@"Illustrations"
                delegate:self
                cancelButtonTitle:@"Cancel"
                destructiveButtonTitle:nil
                otherButtonTitles: @"ABC", @"XYZ",
                nil] autorelease];
UIImage *image = // whatever, snip
if (image != nil)
{
    [actionSheet addButtonWithTitle:@"LMNOP"];
}
它可以有条件地添加我的LMNOP按钮.
...取消按钮后.
如何使用条件按钮构建我的操作表?可悲的是,我做不到:
UIActionSheet *actionSheet = [[[UIActionSheet alloc]
      // ... etc.
      otherButtonTitles: someMutableArray
      // ... etc.
因为那肯定会有所帮助.
有任何想法吗?
谢谢!
ken*_*ytm 53
您可以在init方法之后添加所有按钮.
UIActionSheet* sheet = [[[UIActionSheet alloc] init] autorelease];
sheet.title = @"Illustrations";
sheet.delegate = self;
[sheet addButtonWithTitle:@"ABC"];
[sheet addButtonWithTitle:@"XYZ"];
if (condition)
    [sheet addButtonWithTitle:@"LMNOP"];
sheet.cancelButtonIndex = [sheet addButtonWithTitle:@"Cancel"];
| 归档时间: | 
 | 
| 查看次数: | 9055 次 | 
| 最近记录: |