gpt4 book ai didi

ios - 点击链接时关于UIWebview的问题

转载 作者:行者123 更新时间:2023-11-28 23:15:52 25 4
gpt4 key购买 nike

我有一个加载 html 文件的 UIWebView。用户单击链接后,我希望该 url 在自定义 UIWebview 中打开。我尝试了一些事情:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"MyiPadHTML"
ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:htmlPath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
}

else {
NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"MyHTML"
ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:htmlPath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
}

这是我,正在根据设备加载文件。效果很好。我是在- (void)viewDidLoad方法

中做的

最佳答案

这不可行吗?

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ( navigationType == UIWebViewNavigationTypeLinkClicked ) {
[myOtherCustomWebView loadRequest:request];

return NO;
}

return YES;
}

关于ios - 点击链接时关于UIWebview的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6390364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com