简体   繁体   English

在UIWebView中显示本地网页

[英]Display a local web page in a UIWebView

I am trying to display a local web page in a UIWebView . 我正在尝试在UIWebView显示本地网页。 The local web page is a PHP file and stored in the Supporting Files folder then a folder I created called webpages. 本地网页是一个PHP文件,存储在Supporting Files文件夹中,然后存储在我创建的名为webpages的文件夹中。 I tried this code but it doesn't work. 我试过了这段代码,但是没有用。

@synthesize web;

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"php" inDirectory:@"web"];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [web loadRequest:request];
    [web setDelegate:self];
    [web loadRequest:request];
}

您无法在UIWebView加载PHP文件,因为PHP需要服务器才能运行。

You can't run a local php file through UIWebView. 您不能通过UIWebView运行本地php文件。 PHP is a server side scripting language. PHP是服务器端脚本语言。 OS X (and Windows) don't know how to interpret php code. OS X(和Windows)不知道如何解释php代码。

It seems to be an iPhone app your making, and running local php in your iPhone app is a no-go, and will continue to be for the foreseeable future. 这似乎是您制作的iPhone应用程序,并且在您的iPhone应用程序中运行本地php是不可行的,并且在可预见的将来还将继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM