开发者

html page / faq within iphone app

I am wondering if anyone can advise on the best way to add开发者_Go百科 a FAQ page in iphone app. I would like to display a 'local' file (perhaps HTML) with local images into a web view. Essentialy to enable users access to FAQ within the app.

Any advice on whether to use HTML or any other way of doing this will be very helpful..

Thanks in advance..

mb


I used a UIWebView and loaded a local index.html file into this.

**HelpViewController.h**

@interface HelpViewController : UIViewController {
    UIWebView *webView;
}

@property (retain) IBOutlet UIWebView *webView;

@end

Obviously you will need to @sythesize webView.

**HelpViewController.m**

- (void)viewDidLoad
{
    self.title = @"Help";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleDone target:self action:@selector(btnReturn)];;

    NSString *helpPath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];    
    NSURL *url = [NSURL fileURLWithPath:helpPath isDirectory:NO];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];
    NSLog(@"Help loaded");
}

Hope this helps. Also, just a note, if you are presenting this as a modal, it will appear blank for a split second until the HTML file loads into the UIWebView. I got around this using:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [self performSelector:@selector(showAboutWebView) withObject:nil];          
}

- (void)showAboutWebView {
    [webView setHidden:NO];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜