LoginSignup
0

More than 5 years have passed since last update.

posted at

Xcodeで Could not load the "" image referenced from... が出た時の解決法

事象

XcodeでStoryboardを使ってUIButtonを配置して、そのボタン用の画像を指定しました。でもなんか画像が気に入らないなー。やっぱりこの画像に変えよーっと。という感じで画像を変更しました。
さて動かしてみるとコンソールに

Could not load the "hoge.png" image referenced from... 

と出て、ボタンが表示されない。

色々試行錯誤した結果、

解決法

  1. 画像(上記例だとhoge.png)を削除する。
  2. ボタンも削除する。
  3. 画像のファイル名を変えて(例えばhogeNew.png) File->Add Files .. で読み込む。
  4. StoryBoardで新しくボタン(UIButton)を配置し、ボタンのAttributeで画像(hogeNew.png)を指定する。

原因(推測)

UIButtonのAttributeのImageに画像を指定した後、その画像ファイルを削除し、ButtonのAttribute設定はそのままにしたのが原因かも。
お作法としては、まずButtonのAttributeを変更して、その後に元の画像ファイルを削除するのが正解かもしれません。

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
What you can do with signing up
0