代码之家  ›  专栏  ›  技术社区  ›  Knodel

如何将.rtfd.zip文件加载到ipad uiwebview中

  •  1
  • Knodel  · 技术社区  · 16 年前

    我有一个ipad uiwebview,它必须显示一些rtfd.zip文件。我试着这样做:

    -(void) viewWillAppear:(BOOL)animated {
    
    [self loadFile:string];
    }
    - (void)loadFile:(NSString*)file
    {
    NSString* resourcePath = [[NSBundle mainBundle] bundlePath];
    NSString* sourceFilePath = [resourcePath stringByAppendingPathComponent:file];
    NSURL* url = [NSURL fileURLWithPath:sourceFilePath isDirectory:NO];
    NSURLRequest* request = [NSURLRequest requestWithURL:url];
    [webview loadRequest:request];
    [resourcePath release];
    }
    

    但我只得到一张空白页。这些插座确实连接正确-uiwebview可以加载谷歌主页。

    我做错什么了? 事先谢谢!

    1 回复  |  直到 15 年前
        1
  •  1
  •   Naveen Shan    15 年前

    试着用这个,我用这个得到了输出,

        - (void)loadFile:(NSString*)file    {
    
            UIWebView *webview=[[UIWebView alloc] init];
    
            NSString *FullstrURL=[[NSBundle mainBundle] pathForResource:file 
                                                                 ofType:@"html" ];
            NSLog(@"HTML String = %@",FullstrURL);
           [webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:FullstrURL]]];
    
     }
    
    推荐文章