IOS打开一个本地html,怎么给他带上一个参数

2025-03-01 06:18:41
推荐回答(2个)
回答1:

本地文件不可以url直接加参数,可以在uiwebview 加载好后 用js和oc 交互,传递参数。

参考:

 NSURL *urlNosmoke = [NSURL URLWithString:[NSString stringWithFormat:@"nosmokeProgram.html"]];
    
    NSString *strFilePath = [self.viewController.commandDelegate pathForResource:[urlNosmoke path]];
    
    NSURL *urlNonSmoking = [NSURL URLWithString:@"?nonSmokingId=2013" relativeToURL:[NSURL URLWithString:strFilePath]];
    
    NSURLRequest *req = [[NSURLRequest alloc] initWithURL:urlNonSmoking
                                              cachePolicy:NSURLRequestUseProtocolCachePolicy
                                          timeoutInterval:20.0f];
    
    [self.viewController.webViewEngine loadRequest:req];

回答2:

使用ios中的jsapi调用