Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

idelovski

macrumors regular
Original poster
Sep 11, 2008
235
0
I found something very interesting in iPhone Human Interface Guidelines (HIG) related to UIAlertView.

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];
}
For the risky action I should swap the titles of the buttons. Like this:
Code:
   UIAlertView *cameraAlert = [[UIAlertView alloc]
                     initWithTitle:nil
                           message:@"“Camera” would like to spy on you"
                          delegate:self
                 cancelButtonTitle:@"OK"
                 otherButtonTitles:@"Don't Allow", nil];
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?
 
i don't think it's common to reverse the buttons. the method is clearly labeled. the HIG is dumb. even apple has been known to not follow their own guidelines in certain applications.

nice find, though. submit it to apple. (can you submit a bug for HIG?)
 
I think it's been like this on Mac OS X for a long time. The idea is that many people will just hit the default button on the alert without reading it. If hitting the default button will cause them to lose data then this makes it a little harder for them to do without reading the alert.

I doubt they will reject your app if you violate this but who knows?
 
It used to be like this in the Mac HIG and I assume it's still valid although I haven't read the Mac HIG for a long time.

The principle is based on the fact that people tend to read windows and dialog boxes from the upper left corner to the lower right corner, and the user tends to want to click the button in the lower right corner. So, the "safe" buttons should be on the far right and the "unsafe" buttons should be on the far left side.

If you open a document in TextEdit, make some changes, and try to quit the application you get a dialog box asking if you want to save the file. In this dialog, the "Save" button is on the far right since it's the safe button. The "Cancel" button is also safe, it's also placed on the right side immediately to the left of the "Save" button. The "Don't Save" button is all the way to the left to make sure that the user doesn't select it by accident.
 
Mac had OK on the left up to System 6, but since the System 7 OK is on the right and it makes sense because of several reasons. It's what you said above and it also goes well with arrows as buttons (say in wizards). Left arrow on the left side means "go back" and the right arrow is on the other side meaning "go on".

Back then, when I run my copy of Visual Studio 2003 it had two different scroll bars on the main screen at the same time. One was new, xp-styled scroll bar and the other was old-style, Win 2000 scroll bar. To me it meant they don't really care abut UI rules - Windows is a mess so as a developer I can proceed as I please - make my own guidelines.

Well, Apple should guard iPhone from any such UI confusion that might ruin user's experience. When some unexpected modal window appears user may react with "I don't have time to think about it now" or "How did I get here?" In both cases they might press the Home button and if that means losing some data they would start looking at iPhone the way most people look at Windows.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.