2011-11-17 91 views

回答

1

试试这个:

//Set the URL to go to for your UIWebView 
NSString *webAddressString = @"http://afrikaans.news24.com/Sci-tech/Nuus/Rwanda-gaan-Suid-Afrikaanse-wild-invoer-20111116"; 
NSLog(@"show webAddressString: %@", webAddressString); 

//Create a URL object. 
NSURL *weburl = [NSURL URLWithString:webAddressString]; 
[webAddressString release]; 
//URL Requst Object 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:weburl]; 

//load the URL into the web view. 
[aWebView loadRequest:requestObj]; 

错误101是The operation couldn’t be completed.,由或域导致没有发现,网络问题,甚至(从谷歌搜索)对象分配。

+0

得到它这样的工作,但不幸的是我不能硬编码的URL – RunLoop

+2

发现问题,字符串包含无形的新行字符 – RunLoop

+0

+1妈呀,这是我的问题太多!我以为我疯了。可能很高兴更新您的问题以反映修复。如果你愿意,我会问这个问题。 (几乎用+0跳过了这个问题) – eric

1

尝试像

NSString *unencodedURLString = @"http://afrikaans.news24.com/Sci-tech/Nuus/Rwanda-gaan-Suid-Afrikaanse-wild-invoer-20111116"; 
NSString *encodedURLString = [unencodedURLString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; 

//Create a URL object. 
NSURL *weburl = [NSURL encodedURLString]; 
//URL Requst Object 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:weburl]; 

//load the URL into the web view. 
[aWebView loadRequest:requestObj];