当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - View local html/js contents in mobile safari

问题描述:

I need to view some local (saved somewhere in the iPad) html / js contents with mobile Safari. By reading some threads it seems that the file:// protocol is disabled. Right?

If so, the solution I see is to install an app which turns the iPad into an http server (no need for support of php or anything else), load my contents there and access somehow them within the same device by http://localhost/... or http://127.0.0.1/... with mobile safari.

Is that actually possible? Can someone please suggest me a good web server app which possibly does not require jailbrake or other hacking?

Thanks!

网友答案:

You probably can't do what you want because in order for your application to be serving up HTTP requests to Mobile Safari, it would have to be running in the background, and there's no permissible background mode that covers this.

If you only need a one-time-only response immediately after running your application, then you could possibly use beginBackgroundTaskWithExpirationHandler:, although this might not be approved by Apple - it's difficult to predict their response to that.

If you are sure that you don't need this to go into the App Store, then you can get your application running in the background permanently by abusing one of the other background modes, such as pretending to be a VOIP app or media player.

Once you're running in the background, you can use CocoaHTTPServer to actually serve the files.

If you describe what you are trying to achieve, somebody might be able to suggest an alternative approach to using local files / Mobile Safari.

分享给朋友:
您可能感兴趣的文章:
随机阅读: