将NSArray作为otherButtonTitles传递 - iOS

时间:2011-05-27 11:15:11

标签: iphone ios ipad

目前我正在使用

...otherButtonTitles:@"Hotel Laguna", @"Hotel Village", @"Hotel Torre", @"Hotel Baia", nil];

创建UIActionSheet

我想传递NSArray ......类似于:

    NSArray *names = [[NSArray alloc] 
initWithObjects:@"Hotel Laguna", @"Hotel Village", @"Hotel Torre", @"Hotel Baia", nil];

    ...otherButtonTitles:names];

这有可能吗?

谢谢!

1 个答案:

答案 0 :(得分:5)

如果您在数组中有对象,则可以通过枚举数组来添加otherButtonTitles

(NSString * title in Strings) 

{ 
[alert addButtonWithTitle:title]; 
}