【问题标题】:UIWebView cannot redirectUIWebView 无法重定向
【发布时间】:2011-12-28 17:39:57
【问题描述】:

我是 Objective-C 的新手。

我制作了一个将字符串重定向到 webView 的应用程序。我希望 webView 应该加载维基百科并搜索该字符串中存在的内容。

我是这样写的……

NSString *urlString=[NSString stringWithFormat:@"http://en.wikipedia.org/wiki/Main_Page/search=%@",str1];
//[urlString stringBy];
NSLog(@"url   %@",urlString);
NSURL *url=[NSURL URLWithString:urlString];
NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
[webView loadRequest:request];

【问题讨论】:

  • 插座好像有问题。
  • 您是否已将 webview 添加到屏幕上显示的视图中?

标签: iphone objective-c uiwebview


【解决方案1】:
NSString *urlAddress = @”http://www.google.com”;

// Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];

// URL Request Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

// Load the request in the UIWebView.
[webView loadRequest:requestObj];

祝你好运

【讨论】:

  • 它与问题有什么关系?
  • 请在代码标签之间写代码--> ` .这些字符应位于键盘上“1”键的左侧。感谢并欢迎来到 SO :) 例如code goes here
  • 感谢 iHunter,但实际上我希望我的字符串直接重定向到维基百科,维基百科将搜索该字符串的内容......
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-18
  • 1970-01-01
  • 2016-04-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多