2013年11月25日月曜日

Projectに追加した画像ファイルの場所


UIImage の imageNamed メソッドを使うとUIImageオブジェクトがキャッシュされます。サイズが大きい画像の場合などでキャッシュに残したくない場合はimageWithContentsOfFile メソッドを使用するように書かれています。

imageNamed:
If you have an image file that will only be displayed once and wish to ensure that it does not get added to the system’s cache, you should instead create your image using imageWithContentsOfFile:.

プロジェクトに追加しイメージファイルのパスは次の方法で取得します。

NSString* imgPath =
                  [[NSBundle mainBundle] pathForResource:imgName ofType:@"png"];



0 件のコメント: