+ Reply
Results 1 to 14 of 14

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: UIAlertSheet

is a discussion within the

iPhone / iPod Touch SDK | Development Discussion

forums, a part of the

3rd Party Apps For iPhone | iPod Touch

section;
I'm a rookie on Apple products--I really wish I had known about UIAlertSheet earlier. If you aren't familiar with it, it is essentially like the iPhone version of Java Swing's
...
  1. #1
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    Default UIAlertSheet
    I'm a rookie on Apple products--I really wish I had known about UIAlertSheet earlier. If you aren't familiar with it, it is essentially like the iPhone version of Java Swing's JOptionPane...it can be used to display messages, to get keyboard input, etc.


    Here is a simple message output dialog:
    Code:
    - (void)showMessage: (NSString*) aMessage withTitle: (NSString*) aTitle { 
        
    	[aMessage retain]; //I'm a little paranoid when it comes to memory managmenet
    	[aTitle retain];
    	UIAlertSheet * zSheet;
    	
    	zSheet = [[UIAlertSheet alloc] initWithFrame:CGRectMake(0,240,320,240)];
    	[zSheet setTitle:aTitle];
    	[zSheet setBodyText: aMessage];
    	[zSheet setRunsModal: true]; //I'm a big fan of running sheet modally
    	
    	[zSheet popupAlertAnimated:YES]; //Displays
                  //Pauses here until user taps the sheet closed
                  
    	[zSheet autorelease];
    	[aMessage release];
    	[aTitle release];
    	
    }

  2. #2
    iPhone? More like MyPhone
    Join Date
    Nov 2007
    Location
    In the clouds.
    Posts
    131
    Thanks
    2
    Thanked 16 Times in 11 Posts

    Default Nice
    This look interesting, I also am totally unfamiliar with Apple products, more so than yourself but I can appreciate that this could be useful.

    Do you have any suggestions as to proposed applications andh ow we would run this exactly?

    I'm not sure I understand entirely what this is but if I understand right it's similar to the little blue dialogues that pop up on the iPhone with messages and warning about lack of net connection or no service/invalid sim and all that?

    In that case, it sounds like it could come in handy for a simple pop up to do list that we could enter text into via a text doc or otherwise and click an icon to pop it up.

    Again, another implementation could be an "About Me" what I mean is, information about the owner of the phone in the case that it is lost, it could be returned, you could have it pop up a message with you contact details or a message that it is lost/stolen? Maybe on receipt of a pre-set SMS notification that could casue it to pop up and remain visible indefinately until disabled.

    Correct me though if I am entirely mis-understanding what this is.

  3. #3
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    If I understand, you are talking about the alert sheet sort of serving as a glass pane that intercepts all the user input, preventing them from interacting with the underlying things?

    That may be possible with some fancy configuring...however, it seems the code-lock option that is already built in would be much more effective...just replace the opening image of the Earth with a graphic with what text you want.

    I didn't really look into this class earlier because of the name--I don't think 'alert' is the best description of it. For example, it is incredibly easy to have it ask the user for an input string, bringing up the keyboard and everything. In Garf, I now have it serving as an 'about box', the place to input the initials for high scores, the resulting high score list, an "are you sure?" dialog, and various message dialogs. It really is JOptionPane, Apple style.

  4. #4
    iPhone? More like MyPhone
    Join Date
    Nov 2007
    Location
    In the clouds.
    Posts
    131
    Thanks
    2
    Thanked 16 Times in 11 Posts

    Default No
    No, I wasn't thinking of it prevent access to what's underneath, I simply intend for it to be displayed indefinately on the screen, If you dismiss it, it will pop up again. Or maybe remove the options from it so it can't be dismissed, is that possible?

    But certainly for owner info, exactly like you about box, a simple SpringBoard icon that will pop up one of these to display the owners information which you can dismiss just like any other, in the case that it is found.

    Certainly while it is locked the best idea would be as you suggest to replace the earth image with graphic text.

    I don't know about the owner info thing, it's just an idea.

  5. #5
    Developer
    Join Date
    Jul 2007
    Location
    Chicago, IL
    Posts
    128
    Thanks
    0
    Thanked 18 Times in 13 Posts

    UIAlertSheet is very useful, can be used in many ways. Here are two examples with code from iBlackjack.

    Popup Alert UIAlertSheet


    and

    Sheeted UIAlertSheet


    You can set it to darken the background, prevent the app from running in the background and also change it's style

    Here is some sample code of the bet sheet:

    Code:
    UIAlertSheet betSheet = [ [ UIAlertSheet alloc ] initWithFrame: CGRectMake(0, 240, 320, 240) ];
    [ betSheet setTitle:@"Place A Bet?" ];
    [ betSheet setBodyText:@"Please select the amount of money you'd like to set as your bet amount.  You can change this every hand or let it remain the same." ];
    [ betSheet addButtonWithTitle:@"$20" ];
    [ betSheet addButtonWithTitle:@"$50" ];
    [ betSheet addButtonWithTitle:@"$100" ];
    [ betSheet setDelegate: self ];
    [ betSheet setSuspendTag: YES];
    [ betSheet presentSheetInView: tableView ];
    And here is for the hand over sheet:
    Code:
    UIAlertSheet handOverSheet = [[UIAlertSheet alloc] initWithFrame:CGRectMake(0, 240, 320, 260)];
    [handOverSheet setTitle:status_title];
    [handOverSheet setBodyText:[NSString stringWithFormat:@"%@n%@", status, bankstatus]];
    [handOverSheet addButtonWithTitle:[NSString stringWithFormat:@"Deal! (Bet: $%d)", minimum_bet]];
    [handOverSheet addButtonWithTitle:@"Change Bet"];		
    [handOverSheet setDimsBackground:NO];
    [handOverSheet setDelegate:self];
    [handOverSheet setAlertSheetStyle:0];
    [handOverSheet setSuspendTag: YES];
    [handOverSheet popupAlertAnimated:YES atOffset:150];
    Then to handle it's input, you just create this method in your class because it'll be a delegate for input:

    Code:
    - (void)alertSheet:(UIAlertSheet*)sheet buttonClicked:(int)button
    {
    	if (sheet == betSheet) {
    		if ( button == 1 ) {
    			minimum_bet = 20;
    		} else if ( button == 2 ) {
    			minimum_bet = 50;
    		} else if ( button == 3 ) {
    			minimum_bet = 100;
    		}
    	} else if (sheet == handOverSheet) {
    		if ( button == 1 ) {
    			[self cleanUpGame];
    		} else if ( button == 2 ) {
    			[self showBetSheet];
    		}
        }
    	[sheet dismiss];
    	[sheet release];		
    }
    Actually as of the next version of iBlackjack I don't even use these anymore, changing the game up a bit. Got lots of complaints about them.
    Patrick McCarron
    iPhone Software Engineer @ Mobileage, Inc

  6. #6
    iPhone? More like MyPhone
    Join Date
    Nov 2007
    Location
    In the clouds.
    Posts
    131
    Thanks
    2
    Thanked 16 Times in 11 Posts

    Default Interesting
    These are exactly what I was thinking.

    So, what we need now is for you to tell us what exactly the complaints about them where so why know when we should and shouldn't use them. Is the fact that theyre stealing focus the problem, does the program in the background not pause to wait for input, (does it do the opposite, and the pausing is the problem). Any info is appreciated.

  7. #7
    Developer
    Join Date
    Jul 2007
    Location
    Chicago, IL
    Posts
    128
    Thanks
    0
    Thanked 18 Times in 13 Posts

    Quote Originally Posted by alias_neo View Post
    These are exactly what I was thinking.

    So, what we need now is for you to tell us what exactly the complaints about them where so why know when we should and shouldn't use them. Is the fact that theyre stealing focus the problem, does the program in the background not pause to wait for input, (does it do the opposite, and the pausing is the problem). Any info is appreciated.
    The complaints were mostly that the alert sheet "broke" the flow of the game the users felt. But it was part of the game flow in itself, now I'm changing how the user bets and is presented with the end of the game results.
    Patrick McCarron
    iPhone Software Engineer @ Mobileage, Inc

  8. #8
    iPhone? More like MyPhone
    Join Date
    Nov 2007
    Location
    In the clouds.
    Posts
    131
    Thanks
    2
    Thanked 16 Times in 11 Posts

    Default Hehe
    Fair enough, I will make no comments about the people who play such games, and I personally can't give an opinion on the flow since the game is of no interest to myself.

    Interesting to note though that people feel it affects the flow, these really were intended to make everything else stop and grab your attention, hence them being called AlertSheets.

    Just like dialogs can annoyingly interrupt the flow of other computer related experiences I guess.

  9. #9
    What's Jailbreak?
    Join Date
    Jan 2008
    Location
    San Francisco
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post
    In case you guys didn't know, what we've stumbled onto is the concept of a 'modal window':

    http://en.wikipedia.org/wiki/Modal_window

    The concept of 'breaking' a flow is an age old discussion between modal and modeless windows, and has been the topic of many debates. if you're interested in the subject I'd highly recommend the wikipedia article as a starting point.

  10. #10
    Developer NetMage's Avatar
    Join Date
    Aug 2007
    Location
    Virginia
    Posts
    1,296
    Thanks
    72
    Thanked 210 Times in 168 Posts

    Don't Mode Me In!

    10 points for the source of that quote...

    No fair using Google or Wikipedia...
    Last edited by NetMage; 01-02-2008 at 04:21 PM.
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage

  11. #11
    iPhone? More like MyPhone
    Join Date
    Nov 2007
    Location
    In the clouds.
    Posts
    131
    Thanks
    2
    Thanked 16 Times in 11 Posts

    Default Hmm
    Quote Originally Posted by NetMage View Post
    Don't Mode Me In!

    10 points for the source of that quote...

    No fair using Google or Wikipedia...

    Larry Tesler, of none other than Apple inc itself, if I'm not mistaken. Well fancy that. Oh how things have changed.

  12. #12
    Developer NetMage's Avatar
    Join Date
    Aug 2007
    Location
    Virginia
    Posts
    1,296
    Thanks
    72
    Thanked 210 Times in 168 Posts

    Wow! fast response - another old timer

    Of course, not from Apple at that time...

    I have Byte, August 1981 on my bookshelf here in my office today.
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage

  13. #13
    iPhone? More like MyPhone
    Join Date
    Nov 2007
    Location
    In the clouds.
    Posts
    131
    Thanks
    2
    Thanked 16 Times in 11 Posts

    Quote Originally Posted by NetMage View Post
    Wow! fast response - another old timer

    Of course, not from Apple at that time...

    I have Byte, August 1981 on my bookshelf here in my office today.
    Yikes, 1981? I'm not old enough to have them dating that far back. They belong to my father actually, I grew up reading these magazines of his over and over again when we lived abroad in a foreign country, was the only "english" I saw, must say though, some of the magazines I saw didn't require any reading ....

    The Byte issue I saw that in, it was some time August 1995/1996 because he got it just before we moved there, was one of the newer ones. Didn't mean much to me at the time, I was a kid and was only just about to start following in my fathers footsteps.

    As for reading it again ... lets just say I was looking around recently (a few years ago) for a certain other mag (with no words) and stumbled upon this, finding it more interesting decided to read it again, amongst others.

    P.S. My father is an Engineer, and I'm now on well on my way to becoming a qualified Electronic Engineer and Computer Scientist, Along side my fathers encouragement, those magazines and all the toys and gadgets it grew up with most certainly contributed to my path in life.)

    Although I certainly give neither Apple, nor that article any credit for it

  14. #14
    JLA
    JLA is offline
    Developer
    Join Date
    Oct 2007
    Posts
    224
    Thanks
    1
    Thanked 31 Times in 24 Posts

    Let me just say that the default behavior of the alert sheet is quasi-non-modal...that is, it isn't modal, it's just annoying. (It blocks part of the screen. Buttons can still be pressed where they jut out from underneath, I believe.)

    However, I have a hard time thinking of "non-modal" reasons for me to use this class.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts