Generic “help” view which is accessible from all views in uinavigationView

Assuming an application has many views pushed to a uinavigationViewController, each view is different in content.

since the elements in the app are complex, I would like to show a small help view for specific views or elements in a specific view. Imagine a "?" button that when pressed on will pop a new view in the center of the screen, playing youtube help video, or just a textual HTML loaded from a remote server.

Question: what is the best strategy for doing such a thing? where should I place this code (App Delegate?)

if so, how would I call it from other views (with URL Parameter)

-(void)showHelpView:(NSString *)theURLString{

    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)];

    //webView.delegate= self;
    [webView  loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:theURLString]]];
    [window addSubview:webView];
    [window makeKeyAndVisible];
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{

}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{

}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
}

Answers


I'd prefer using pseudo-modal views. So that you create view every time, and add it on top of current window. I've used this approach for OAuth 2.0 authorisation popup in my last app.

Basically you create custom UIViewController subclass, provide custom initialisator, such as, for example:

// - (id) initWithURL: (URL*)url {
// ...
// self.url = url;
// ...
// return self;

PseudoModalViewController* pmvc = [[PseudoModalViewController alloc] initWithURL:@"http://www.google.com/"];

After you've created view you add it on top of current window:

UIWindow* window = [[UIApplication sharedApplication] keyWindow];
if(!window)
{
    window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
}
[window addSubview:pmvc.view];

In, for example, viewDidLoad you load url obtained in initialisator:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
}

You may even design UI in Interface Builer for that. As a last piece I'd recommend add to include full screen transparent background view to ensure that all views below are disabled.

Oh, almost forgot, you hide that view with just a simple [self.view removeFromSuperview]. Don't forget to provide correct memory management for that view (i.e. release it in time, etc).


Need Your Help

My Wordpress home page runs very slow only on Chrome

jquery wordpress performance google-chrome slider

I have noticed that my Wordpress site's homepage runs extremely slow only on Chrome. The hover on the menus takes a few seconds to show. The site runs smoothly if I disable the slider, but I need the

iPad jailbreak affect original application development?

ios ipad jailbreak

I am iOS developer.Now, I develop iPad an iPhone apps for my company. I have an iPad and now I have decided to buy my own Mac ;). I would like to develop applications to then upload to the AppStore...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.