1

次のコードを使用して、plist から webView に html ファイルをロードする際に問題が発生しました

FAQDetailViewController.m:

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *Path = [[NSBundle mainBundle] bundlePath];
    NSString *WebPath = [Path stringByAppendingPathComponent:WebFile];
    UIWebView *tempWeb = [[UIWebView alloc] initWithContentsOfFile:WebPath];
    [webView loadData:tempWeb]; //私の問題はここにあると思います。ここでコードを実装する方法がわかりません
    [tempWebリリース];
}

ここでは、FAQViewController.m にこの平和なコードをロードします。

FAQDetailViewController *faqdvController = [[FAQDetailViewController alloc] initWithNibName:@"FAQDetailView" bundle:[NSBundle mainBundle]];
faqdvController.WebFile = [dictionary objectForKey:@"faqDesc"]; //ここに配置された plist ファイルの html ファイル
faqdvController.hidesBottomBarWhenPushed = NO;
[self.navigationController pushViewController:faqdvController アニメーション:YES];
[faqdvController リリース];
4

1 に答える 1

1

この方法で試すことができます:

NSString *bundle = [[NSBundle mainBundle] bundlePath];
NSString *webPath = [bundle stringByAppendingPathComponent:{htmlFilename}]
UIWebView* browser = [[UIWebView alloc] initWithFrame:
                              CGRectMake(0, 0, 200, 300)];
[browser loadRequest:[NSURLRequest requestWithURL:
                              [NSURL fileURLWithPath:webPath]]];
[self addSubview:browser];

また、コンテンツの読み込みが完了したときに通知されるように、ブラウザーにデリゲートを設定することもできます。

于 2009-10-13T04:23:14.560 に答える