【问题标题】:Can't open specific URL in UIWebView无法在 UIWebView 中打开特定 URL
【发布时间】:2013-06-19 07:06:47
【问题描述】:
NSString *urlAddress;
urlAddress = @"http://ob.carptown.net";
NSURL *url =[NSURL URLWithString:urlAddress];

NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[page loadRequest:requestObj];
[page addSubview:activityView];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0)
                                         target:self 
                                       selector:@selector(loading)
                                       userInfo:nil repeats:YES];
goBack.enabled = page.canGoBack;
goNext.enabled = page.canGoForward;

UIViewView 无法打开上述网址 (http://ob.carptown.net)。
我测试了另一个 URL,UIViewView 打开了它们。但是 URL 可以在 Safari 中打开。 我想要打开 safari 的 URL,我想像 UIWebView 一样控制 safari。

我该怎么做?

【问题讨论】:

  • 您希望 webView 在应用内打开还是转移到独立的 safari 应用?
  • 我只想打开网址(ob.carotown.net)。
  • 不离开应用程序?
  • 是的,不用我的应用程序就可以离开。

标签: objective-c uiwebview


【解决方案1】:
NSString *urlAddress = @"http://ob.carptown.net";

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

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

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

remove NStimer and check it again it will work fine

【讨论】:

    【解决方案2】:

    如果您检查返回的 HTML,服务器会给您一个空的 <body> 标记(谷歌分析除外)。看起来您在页面加载后有 javascript 呈现内容。 UIWebView 似乎无法执行此操作。仅当从横向和向后更改方向时(Cmd + left arrowCmd + right 箭头彼此快速地相互连接),它才会重新加载页面。不幸的是,我不知道为什么会发生这种情况

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-02
      • 2021-02-08
      相关资源
      最近更新 更多