是否可以覆盖UIWebView中的URL?例如,如果我想检测tel:links并将+1加到数字的开头,如果它还没有.
在Android上我这样做:
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:1")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(url));
startActivity(intent);
}
else if (url.startsWith("tel:")) {
int start = url.indexOf(":");
String suffix = url.substring(start + 1);
String newUrl = "tel:1" + suffix;
Intent intent = new Intent(Intent.ACTION_DIAL,
Uri.parse(newUrl));
startActivity(intent);
}
else if(url.startsWith("http:") || url.startsWith("https:")) {
view.loadUrl(url);
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
我怎么能在Objective-C中做到这一点?