我已经尝试了以下代码,但只otherButtonTitles
显示了第一个。
- (id)initWithCancelButtonTitle:(NSString *)cancelButtonTitle primaryButtonTitle:(NSString *)primaryButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...
{
self = [self init];
if (self)
{
// Build normal buttons
va_list argumentList;
va_start(argumentList, otherButtonTitles);
NSString *argString = otherButtonTitles;
while (argString != nil)
{
UIButton *button = [self buildButtonWithTitle:argString];
[self.buttons addObject:button];
argString = va_arg(argumentList, NSString *);
}
va_end(argumentList);
// Build cancel button
UIButton *cancelButton = [self buildCancelButtonWithTitle:cancelButtonTitle];
[self.buttons insertObject:cancelButton atIndex:0];
// Add primary button
if (primaryButtonTitle)
{
UIButton *primaryButton = [self buildPrimaryButtonWithTitle:primaryButtonTitle];
[self.buttons addObject:primaryButton];
}
// Add destroy button
if (destructiveButtonTitle)
{
UIButton *destroyButton = [self buildDestroyButtonWithTitle:destructiveButtonTitle];
[self.buttons insertObject:destroyButton atIndex:1];
}
}
return self;
}
如何修改它?