Question

I'm using this code:

UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTitle:@"Select Tutorial"];
[alert setMessage:@""];
[alert setDelegate:self];
[alert addButtonWithTitle:@"Basic"];
[alert addButtonWithTitle:@"Advanced"];
alert.tag = e_VTselecttutorial;
[alert show];
[alert release];

It produces a window with two buttons, and it all works the way I want except for a graphic problem. Neither button is preferred, and the Advanced button comes up highlighted. It's like it thinks Basic is a Cancel button, and Advanced is an OK button. I've checked cancelButtonIndex, and it's -1 as I expect.

I want both buttons to look the same, and I can't figure out how to do this.

Was it helpful?

Solution

If you combine everything into one line you can do so much easier.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Select Tutorial" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Basic", @"Advanced", nil];

Have you looked at an Action Sheet for this? According to the Apple Human Interface Guidelines:

Alerts give people important information that affects their use of the application (or the device). The arrival of an alert is usually unexpected, because it generally tells people about a problem or a change in the current situation that might require them to take action.

Action sheets give people additional choices related to the action they are currently taking. People learn to expect the appearance of an action sheet when they tap a toolbar button that begins either a potentially destructive action (such as deleting all recent calls) or an action that can be completed in different ways (such as a send action for which users can specify one of several destinations).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top