-1

我能够将本地文件从 iTunes 文件共享(例如“index.htm”)加载到 web 视图中

我的问题在于当我尝试从搜索文本 uitextbox 打开链接时。在这里,我搜索字符串“mow now”

NSString *currentURL = [viewWeb.request.URL absoluteString];
//cleanup
NSString *match = @"Documents/";
NSString *preTel;
NSString *postTel;

NSScanner *scanner = [NSScanner scannerWithString:currentURL];
[scanner scanUpToString:match intoString:&preTel];
NSString *finalString = [NSString stringWithFormat:@"%@contents/search.htm?search=%@&menu=0&submitType=Search", preTel,fixedSpaces];

file:///var/mobile/Applications/################/contents/search.htm?search=mow+now&menu=0&submitType=Search

### = 我的 iphone 沙盒代码(我认为?)

NSString *fullURL = finalString;
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[viewWeb loadRequest:requestObj];

..和页面不加载。:(

4

1 回答 1

0

修复:缺少的是 stringWithFormat 中的“文档”(区分大小写)。

NSString *finalString = [NSString stringWithFormat:@"%@Documents/contents
                         /search.htm?search=%@&menu=0&submitType=Search",
                           preTel,fixedSpaces];
于 2012-12-09T02:29:49.557 回答