打开链接,以http开头,但不以www开头 [英] Open link starting with http but not www
本文介绍了打开链接,以http开头,但不以www开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打开以www开头的链接,但它们没有打开.我的代码仅适用于http.请帮助>我是iOS的新手.我非常有责任.
I want to open link starting with www they do not open. My code working only for http. Please help > I am newer in iOS.I shall be highly obliged.
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
NSLog("User tapped a link.");
}
if ([request.URL.absoluteString rangeOfString:@"iosscrollposition:"].location != NSNotFound) {
NSString *positionString=[[[request URL]absoluteString] stringByReplacingOccurrencesOfString:@"iosscrollposition:" withString:@""];
NSArray *positionArray=[NSArray arrayWithArray:[positionString componentsSeparatedByString:@","]];
NSInteger x=[[positionArray objectAtIndex:0] integerValue];
NSInteger y=[[positionArray objectAtIndex:1] integerValue];
if (initialYPosition != y || y==0) {
if (initialYPosition!=0 ||x==0) {
[myScrollView setContentOffset:CGPointMake(myScrollView.contentOffset.x,myScrollView.contentOffset.y+20) animated:NO];
}
initialYPosition=y;
}
if (x>320) {
[webViewScrollView setContentOffset:CGPointMake(x-300,webViewScrollView.contentOffset.y) animated:NO];
} else if(x<320) {
[webViewScrollView setContentOffset:CGPointMake(0,webViewScrollView.contentOffset.y) animated:NO];
}
return NO;
} else if([request.URL.absoluteString rangeOfString:@"http://"].location == NSNotFound) {
return YES;
} else {
return NO;
}
}
推荐答案
NSURL *url=[NSURL URLWithString:@"http://"];
[self.myWebView loadHTMLString:tempString baseURL:url];
这篇关于打开链接,以http开头,但不以www开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文