Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UIWebView未打开iphone应用程序中的链接_Iphone_Ios_Uiwebview - Fatal编程技术网

UIWebView未打开iphone应用程序中的链接

UIWebView未打开iphone应用程序中的链接,iphone,ios,uiwebview,Iphone,Ios,Uiwebview,我有UIWebView,我想在其中加载链接,但它没有显示任何东西,这是我正在使用的代码,它没有显示 文件名有值 尝试这样做,将fileURLWithPath替换为URLWithString NSString *fileName= @"http://www.google.com"; NSURL *url = [NSURL URLWithString:fileName]; NSURLRequest *request = [NSURLRequest requestWithU

我有UIWebView,我想在其中加载链接,但它没有显示任何东西,这是我正在使用的代码,它没有显示

文件名有值


尝试这样做,将
fileURLWithPath
替换为
URLWithString

    NSString *fileName= @"http://www.google.com";

    NSURL *url = [NSURL URLWithString:fileName];

    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webview setScalesPageToFit:YES];

    [webview loadRequest:request];

**fileURLWithPath**
在存在包含URL的路径时使用

但在您的情况下,有一个直接的URL,所以您应该像下面这样使用

 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",@"http://www.google.com"]];

NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];

[webView loadRequest:request]; 
注意:别忘了将
webView
添加到
self.View
如果使用
XIB
添加,请确保连接正确

试试这个

 UIWebView * aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    NSString *fileName= @"http://click-labs.com";

    NSURL *url = [NSURL URLWithString:fileName];

    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [aWebView setScalesPageToFit:YES];

    [aWebView loadRequest:request];
    [ self.view addSubview:aWebView];

@本机开发人员:然后检查您的IBOutlet连接。@本机开发人员:IBOutlet连接中存在最大问题,如果您的webview是通过编程方式创建的,请检查您的框架。请尝试使用“我的编辑”answer@native下面的所有答案都是完美的,首先检查您的webView是否与iBolate连接。。?来自锡伯。@Nitinghel不明白你为什么告诉我这些。我在评论中也问过同样的问题,如果这也不起作用,那么让我知道你是如何使用webView的。我的意思是从xib或编程
//Create a URL String.
NSString *urlString = [NSString stringWithFormat:@"http://www.google.com"];
//Create a Legeal URL object.
NSURL *MyUrl = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:MyUrl];
// set Fit page to WebView
[webView setScalesPageToFit:YES];
//Load the request in the UIWebView.    
[webView loadRequest:requestObj];
 UIWebView * aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    NSString *fileName= @"http://click-labs.com";

    NSURL *url = [NSURL URLWithString:fileName];

    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [aWebView setScalesPageToFit:YES];

    [aWebView loadRequest:request];
    [ self.view addSubview:aWebView];