iPhone HTTP服务器可在模拟器上运行,但不能在iPhone设备上运行 [英] iPhone HTTP server works on simulator but not on iPhone device

查看:112
本文介绍了iPhone HTTP服务器可在模拟器上运行,但不能在iPhone设备上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将网络服务器嵌入iPhone应用程序中,以便从应用程序的文档目录下载文件.我正在使用 iPhone Http服务器.

I want to embed a webserver in an iPhone app so as to download files from application's document directory. I am using iPhone Http Server.

一切都可以在iPhone模拟器上正常运行.甚至我也可以使用http://:或localhost:来获取文件.

Everything works fine on iPhone simulator. Even I am able to get files using http://: or localhost:.

但是在设备上我无法连接. Safari表示:无法打开页面".甚至 http://iphone.local :在安装了应用程序的同一设备上也无法正常工作.

But on device I am not able to connect. Safari says: "Cannot open page". Even http://iphone.local: doest not work on same device as app is installed.

请提出建议.

推荐答案

您的应用进入后台了,不是吗?我认为您在iOS Simulator中尝试应用程序时会使用Mac的Safari.当您在iPhone上试用时,您的应用程序处于后台,而iPhone的Safari处于前台.

Your app goes into background, doesn't it? I think you use Mac's Safari when you try your app in iOS Simulator. And when you try it on iPhone, your app is in background and iPhone's Safari is foreground.

如果是这样,我相信以下内容会对您有所帮助:

If so, I believe the following helps you:

cocoaHTTPServer无法在后台运行. 尝试让您的应用程序处于前台,并从其他计算机上访问它.

cocoaHTTPServer doesn't work in background. Try keep your app foreground and access it from other machine.

而且,没有办法一直保持服务器功能... https://devforums.apple.com/message/706241

And, there is no way to maintain server functionality all the time... https://devforums.apple.com/message/706241

这篇关于iPhone HTTP服务器可在模拟器上运行,但不能在iPhone设备上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆