views:

552

answers:

3

I like the effect used in many iPhone apps where a semi-transparent help screen slides from the top (or bottom) on top of the current view to show hints or tips. This screen often has a close button as well as "don't show this again" button.

What's the best approach to slide a view on top of the current view for such an effect? Any code example someone can point me towards?

Thanks

+6  A: 

You will want to do something like this from the main view controller..

-(void)showHelp
{
     HelpViewController *controller = [[HelpViewController alloc]init];
     [self presentModalViewController:controller animated:YES];
     [controller release];
}

and the done button would either call back to the main controller or dismiss itself using

- (void)dismissModalViewControllerAnimated:(BOOL)animated

Here is the documentation on the UIViewController class. The methods you require can be found there.

The don't show again feature means you will have to save their selection to NSUserDefaults or somewhere else(sqllite,file system). Then you can read that back when your app launches to determine if you should call showHelp.

Jab
+1  A: 

From your description, and looking at iPhone Human Interface Guidelines, you want UIActionSheet since a modal view isn't semi-transparent by default.

UIActionSheet is also nicer to work with for what you want. You should be able to achieve your goal in a single line.

freespace
+1  A: 

I wrote a short blog post to demonstrate the solution I came up with to slide views on/off screen in the iPhone:

Sliding Views on/off screen on the iPhone

John