uiwebpage无法加载

时间:2011-08-23 12:53:48

标签: objective-c xcode ios4 uiwebview

我正在尝试加载基本网页,但它没有加载。它有点奇怪......

我有这段代码(这不起作用)

    NSString *test = [item objectForKey:@"link"];
    NSLog(@" %@",test); // returns http://westminsteriphone.wordpress.com/2011/08/23/another-blog-post/
[itemSummary loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:test]]];  

但如果我试试..

[itemSummary loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://westminsteriphone.wordpress.com/2011/08/23/another-blog-post/"]];

它的工作原理..:为什么第一个例子没有加载

2 个答案:

答案 0 :(得分:0)

试试这个

 NSString *test = [item objectForKey:@"link"];
    NSLog(@" %@",test); // returns http://westminsteriphone.wordpress.com/2011/08/23/another-blog-post/
[itemSummary loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",text]]]]; 

答案 1 :(得分:0)

试试这个

[itemSummary loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[item objectForKey:@"link"]]]]]; 

如果你在不同的功能中使用这两行,那么就这样做

 function 1

 NSString *test = [[NSString alloc]init];

 test =[NSString stringWithFormat:@"%@",[item objectForKey:@"link"]];


 return [test autorelease];



 function 2



 [itemSummary loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:test]]];