【发布时间】:2019-04-18 20:22:14
【问题描述】:
我的应用中有一个 WKWebview 并加载本地 .html 文件。
我想使用深层链接重定向特定页面。
我不知道该怎么做。
你们有什么想法吗?请告诉我一个解决方案?
深层链接示例:
helloAPP://index.html#/article/list/123345
代码:
@property (strong, nonatomic) IBOutlet WKWebView *webView;
- (void)viewDidLoad {
self.webView = [self.webView initWithFrame:[UIScreen mainScreen].bounds configuration:[self createWKWebApp]];
[self.webView setNavigationDelegate:self];
[self.webView setUIDelegate:self];
[self.webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
self.webView.scrollView.bounces = NO;
[self.webView setContentMode:UIViewContentModeScaleAspectFit];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www/phoneApp"]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:180];
[request setHTTPMethod:@"POST"];
[self.webView loadRequest:request];
}
【问题讨论】:
标签: html ios objective-c wkwebview deep-linking