简体   繁体   English

Apple触控图标未显示在主屏幕上

[英]Apple touch icon isn't showing up on the home screen

I'm using the following code to get touch icons for mobile devices - it's based on the html5boilerplate/mobile example: 我正在使用以下代码来获取移动设备的触摸图标 - 它基于html5boilerplate / mobile示例:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">

<!-- For iPhone 4 with high-resolution Retina display: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/touch/h/apple-touch-icon.png">
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon-precomposed" href="/img/touch/l/apple-touch-icon.png">
<!-- For nokia devices: -->
<link rel="shortcut icon" href="/img/touch/apple-touch-icon.png">

<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

But for some reason, the iPhone is still giving me problems for the home screen icon. 但由于某种原因,iPhone仍然给我主屏幕图标的问题。 All I get is that annoying screenshot icon. 我得到的就是烦人的截图图标。

I've included the other meta tags here in case they shed some light on why it isn't working. 我已经在其中包含了其他元标记,以防它们解释为什么它不起作用。 I've tried reordering the tags. 我试过重新排序标签。

Can anyone think of anything that might stop the icons being used? 谁能想到任何可能阻止图标被使用的东西?

I've used html5boilerplate/mobile as a test case - I'm able to browse to their site and add the icon to the home screen on my iPhone (4S iOS5). 我使用html5boilerplate / mobile作为测试用例 - 我可以浏览他们的网站并将图标添加到我的iPhone(4S iOS5)的主屏幕上。 I've tried copying their code, folder structure, and icons into my own site, but this didn't work. 我已经尝试将他们的代码,文件夹结构和图标复制到我自己的网站中,但这不起作用。

Any ideas? 有任何想法吗?

I had the same problem. 我有同样的问题。 The solution is to remove the password protection on the website. 解决方案是删除网站上的密码保护。

I put the same page and icon on two other sites and it worked perfectly, so I think maybe it might be because the original two test servers I was working on were password protected - although obviously I'd entered the credentials to browse the page, so not entirely sure why that would be a problem. 我在其他两个网站上放了相同的页面和图标,它工作得很好,所以我想也许可能是因为我正在处理的原始两个测试服务器都受密码保护 - 虽然很明显我输入了浏览页面的凭据,所以不完全确定为什么会出现这个问题。 However, the results appear to suggest this was the case. 但是,结果似乎表明情况就是这样。

In the Apple Safari Web Content Guide they suggest putting the icons in the "root document folder". 在Apple Safari Web内容指南中,他们建议将图标放在“根文档文件夹”中。

To specify an icon for the entire website (every page on the website), place an icon file in PNG format in the root document folder called apple-touch-icon.png or apple-touch-icon-precomposed.png. 要指定整个网站的图标(网站上的每个页面),请将PNG格式的图标文件放在名为apple-touch-icon.png或apple-touch-icon-precomposed.png的根文档文件夹中。

I tried this and it wouldn't work until I finally moved the icons to an 'img' folder and linked to them there. 我尝试了这个,直到我最终将图标移动到'img'文件夹并在那里链接到它们之后它才会起作用。

However, I suspect the reason the html5boilerplate icon worked and yours didn't was because you are using a virtual directory such as: 但是,我怀疑html5boilerplate图标工作的原因和你的不是因为你使用的是虚拟目录,例如:

http://localhost/myvirtualdirectory/apple-touch-icon.png

while the default behavior of iOS is to look at the root domain even when you are hosting out of the virtual directory: 而iOS的默认行为是查看根域,即使您正在托管虚拟目录时:

http://localhost/apple-touch-icon.png

Hopefully others could verify this. 希望其他人可以验证这一点。

I had the very same problem, and the source of the problem is that I had an htaccess file with password protection for my site, so the webclip icon will not work, to solve this problem and still have password protection you need to add this code: 我有同样的问题,问题的根源是我有一个htaccess文件,我的网站有密码保护,所以webclip图标不起作用,解决这个问题,仍然有密码保护,你需要添加这个代码:

SetEnvIf Request_URI "(/apple-touch-icon\.png)$" allow
Order allow,deny
Allow from env=allow
Satisfy any

That way you have full access to http://www.example.com/apple-touch-icon.png without needing any password. 这样您就可以完全访问http://www.example.com/apple-touch-icon.png而无需任何密码。

If you are still having problems here is an example with the full htaccess file: 如果您仍然遇到问题,请参阅完整的htaccess文件示例:

AuthUserFile /home/mysite/.htpasswds/.htpasswd
AuthType Basic
AuthName "Password Protected"
Require valid-user
SetEnvIf Request_URI "(/apple-touch-icon\.png)$" allow
Order allow,deny
Allow from env=allow
Satisfy any

That should fix the problem. 这应该解决问题。

Cheers!! 干杯!!

I had the same problem when my icons were in my ui/img folder, even though my site wasn't password protected. 当我的图标在我的ui / img文件夹中时,我遇到了同样的问题,即使我的网站没有密码保护。 After moving them to my root folder (and clearing the cache) it started working. 将它们移动到我的根文件夹(并清除缓存)后,它开始工作。

在外部图像托管上放置一个图标并添加URL作为“href”的值对我来说是有魅力的。

直到我在“设置” - >“Safari”下运行我的iPhone,然后“清除历史记录和网站数据”,然后尝试将其添加到我的主页,我无法使用此功能。

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

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