Reputation: 4287
I have a UIActionSheet in my app that defaults to having 4 buttons. If a user customises an image the action sheet gains an extra 5th button allowing the user to reset this image.
I'm using this delegate method to determine which action sheet button has been clicked:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
The problem is the cancel button is at buttonIndex 2 by default but when the 5th button is present it is at buttonIndex 3. Is there anyway from knowing the buttonIndex you can access the title/name of the action sheet button?
Upvotes: 2
Views: 4687
Reputation:
Yes you can ask the action sheet for the button title at given index using :
-(NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;
Alternatively, UIActionSheet
defines a property :
@property(nonatomic) NSInteger cancelButtonIndex;
Upvotes: 8