【问题标题】:UIWebview open local webpage with QuerystringsUIWebview 使用查询字符串打开本地网页
【发布时间】:2016-02-01 14:35:05
【问题描述】:

我想打开一个本地存储在 UIWebview 中的网页。那不是问题。但我想用 URL 中的一些 GET 数据打开它。 现在我正在使用以下代码。

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"start" ofType:@"html" inDirectory:@"flir/pages"]];
self.webView.delegate = self;
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];

这将打开 start.html。但是我真正想打开的 URL 是 start.html?var1=abc&var2=xyz。我怎样才能做到这一点 ?

【问题讨论】:

    标签: ios uiwebview


    【解决方案1】:

    你可以这样做

    NSString* filePath = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"html"];
    NSString* url = [NSString stringWithFormat:@"file://somepath%@?var=%@", filePath, @"bar"];
    NSURL* fileURL = [NSURL URLWithString:url];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 2019-08-22
      • 1970-01-01
      相关资源
      最近更新 更多