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

2025年03月01日 06:18
有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调用