I found something very interesting in iPhone Human Interface Guidelines (HIG) related to UIAlertView.
So for a normal, benign action (as pictured in the that link above) I should handle alert like this:
For the risky action I should swap the titles of the buttons. Like this:
Is this common? Does anyone know of such an application?
And this doesn't make any sense to me because if user pressed home button on the device, my delegate would receive index of cancel button, but in this case buttonIndex of 0 means Go Ahead. Am I missing something?
In an alert with two buttons, the button on the left is always dark-colored and the button on the right is never dark-colored.
* In a two-button alert that proposes a potentially risky action, the button that cancels the action should be on the right and light-colored.
* In a two-button alert that proposes a benign action, the button that cancels the action should be on the left (and therefore dark-colored).
So for a normal, benign action (as pictured in the that link above) I should handle alert like this:
Code:
- (IBAction)showCameraAlert:(id)sender
{
UIAlertView *cameraAlert = [[UIAlertView alloc]
initWithTitle:nil
message:@"Camera would like to use your current location"
delegate:self
cancelButtonTitle:@"Don't Allow"
otherButtonTitles:@"OK", nil];
[cameraAlert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView) {
NSLog (@"Button %d pressed.", buttonIndex);
}
[alertView release];
}
Code:
UIAlertView *cameraAlert = [[UIAlertView alloc]
initWithTitle:nil
message:@"Camera would like to spy on you"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:@"Don't Allow", nil];
And this doesn't make any sense to me because if user pressed home button on the device, my delegate would receive index of cancel button, but in this case buttonIndex of 0 means Go Ahead. Am I missing something?