How to create "otherButtonTitles"?

I have an AlertView that works fine with “cancelButtonTitle: @“ Cancel ”and“ otherButtonTitles: nil. ”My question is how to get other buttons.

When I change only "otherButtonTitles: @" 2nd Button ", the iPhone simulator crashes from the application and onto the desktop.

+3
source share
2 answers

You want to end the method call as follows:

... cancelButtonTitle:@"Cancel" otherButtonTitles:@"Button1Title", @"Button2Title", nil];

This is the same pattern that you see in line formatting, where the argument list can be any length. Typically, the argument list then ends with nil. Do not forget that zero.

+10
source

, .

UIAlertView, delegate self, :

-(void) alertView: ( UIAlertView *) alertView 
         clickedButtonAtIndex: ( NSInteger ) buttonIndex {
      // do stuff
      // if you want the alert to close, just call [ alertView release ]   
}

`

+6

Source: https://habr.com/ru/post/1726498/


All Articles