LoginSignup
8
8

More than 5 years have passed since last update.

iphoneの「ホーム画面に追加」の画像を固定したい....!

Last updated at Posted at 2016-08-12

「ホーム画面に追加」の画像は、何も指定しなかったらiosくんが結構適当に選んでしまう

そもそもホーム画面に追加」の画像を固定するにはいくつかの決まりがあって

1. 画像の名前

apple-touch-icon.png
である必要があります!
これは拡張子まで一緒で、例えば
apple-touch-icon.jpeg
とかだと動きません。。。。
めんどくさい
さらに大きさも144px × 144px でないといけません

2. ディレクトリ構成

作りたいwebサイトのrootディレクトリ配下でアクセスできる必要があります
つまり、 http://example.com/apple-touch-icon.png
でアクセスできる必要があります

Railsでやると....

これがちょっと厄介でRailsではアセットコンパイルというjsや画像などはコンパイルして軽くする、といった手法が取られていて、例えば
image_urlimage_tag で画像をとるとコンパイルされためちゃめちゃな文字列の名前になってしまいます。。。
これでは、 apple-touch-icon.pngという名前である、という条件が満たされないことと、さらに asset/からのディレクトリ名になってしまったりと、いろいろ満たしきれなくなってしまいます

結果

public配下に apple-touch-icon.png144px × 144pxでおいて

application.html.haml
%link{:href => "apple-touch-icon.png", :rel => "apple-touch-icon"}

と書けば、うまくいきます

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8