I have a requirement in an application where I need to be able to add otherButtonTitles dynamically, dependent upon some BOOL switches that a user has specified in the settings. However, I can’t seem to figure out how to go about doing this in the UIActionSheet initialization. I’ve tried to pass a NSString array (NSString[2]), and also a NSArray without any luck.
Any help here is greatly appreciated.
The easiest way to do this that I have found is initially create your action sheet with no buttons, including no cancel or destructive button:
Then add a load of buttons as needed:
Then finally add the cancel button at the end and set the cancel button index:
Of course you can add both a cancel button and/or a destructive button in this way.