Strange issue in iPhone HIG - UIAlertView

Discussion in 'iOS Programming' started by idelovski, Sep 25, 2009.

  1. idelovski macrumors regular

    Joined:
    Sep 11, 2008
    #1
    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:
    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?
     
  2. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #2
    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?)
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    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?
     
  4. bredell macrumors regular

    Joined:
    Mar 30, 2008
    Location:
    Uppsala, Sweden
    #4
    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.
     
  5. idelovski thread starter macrumors regular

    Joined:
    Sep 11, 2008
    #5
    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.
     

Share This Page