Chris
Chris

Reputation: 27384

iOS: Creating tip / help popups

Are there any built in, open source, or tutorials for creating a reusable easy to use popup for use with in game-help.

Essentially I would like to, on first run of a game, show popup tips / help that "point to" various on screen objects to help a user orient themselves with the game.

Update: Here is an example of how I ultimately want it to look / behave although I don't need it that generic but as close as possible would be good

Upvotes: 13

Views: 6960

Answers (5)

SaKKo sama
SaKKo sama

Reputation: 61

How about this? I wrote this myself. It's pretty simple and probably what you are looking for. Popup any UIView instance on top or bottom then disappear after a few seconds.

https://github.com/SaKKo/SKTipAlertView

Hope you find it useful. cheers,

Upvotes: 0

Dream Lane
Dream Lane

Reputation: 1312

In my App, the tips were fairly static, so I created an tip image using my favorite image editor, and then simply created a UIImageView with the tip image, and then added that as a subview to the current view, making sure to place it on top of other views.

It worked out pretty nicely, but again, my tips are fairly static.

If you want to display them only on the first run through, you'll need to create a BOOL that is saved in NSUserDefaults or something.

Upvotes: 1

Shmidt
Shmidt

Reputation: 16664

I like those: https://github.com/chrismiles/CMPopTipView.

Nice and easy to set up.

Upvotes: 7

greenhorn
greenhorn

Reputation: 1107

What I've done is to create two functions

- (void) showOverlay: (BOOL) show withMessage: (NSString*) message
{
    if(show)
    {
        // I create or load a UIView with labels, etc, and with an alpha of 0.6/07
        // give it a tag for later dismissal
        overlay.tag = tag; // any arbitrary value

        // add as subview
        [self.view addSubview: overlay];
    }
    else
    {
        // hide the view
        UIView *overlay = [self.view viewWithTag: tag];
        [overlay removeFromSuperview];
    }
}

Then I have a hide overlay function

- (void) hideOverlayInSecs: (NSInterval) time
{
    [self performSelector: @selector(hideOverlay) withObject: nil afterDelay: time];
}

Then you can write a wrapper function to show / dismiss it for varying durations

[self showOverlay: YES withMessage: @"help tip"];
[self hideOverlayInSecs: 2];

Upvotes: 4

Manlio
Manlio

Reputation: 10865

Essentially what you need is a custom view.

You cannot use Apple's UIAlertView since its purpose is very different from what you are looking for.

I don't know what are your specific needs, but you may use a simple UILabel:

CGRect ref = objectToAddress.frame;

UILabel *tip = [[UILabel alloc] initWithFrame:CGRectMake(ref.x+ref.width, 
                                                         ref.y+ref.height,
                                                         width,
                                                         height)];

[tip setText:messageToShow];

[self.view addSubview:tip];
[tip release];

where width and height are the dimensions of the tip you want to show and messageToShow is the message you want to display.
You can, of course, customize your UILabel as you like, changing font or background color. Check the reference for additional informations.

EDIT:

You may take a look at a possible popover implementation for iPhone: WEPopover. On the iPad you can use directly Apple's UIPopoverController

Upvotes: 4

Related Questions