Wie NSBundle pathForResource:ofType: und UIImage imageWithContentsOfFile: handle Skala und Gerät Modifikatoren?

In meinem iOS-Ressource-Ordner, ich habe die Bilder:

foo~iphone.png
foo@2x~iphone.png
foo~ipad.png
foo@2x~ipad.png

Lade ich Sie mit:

NSString *fileName = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:fileName];

Experimentell:

Auf dem iPhone filename ist /path/to/bundle/foo~iphone.pngund auf dem retina-iPhone, es lädt die @2x version.

Auf dem iPad filename ist /path/to/bundle/foo~ipad.pngund auf dem retina-iPad, lädt es die @2x version.

Ist, lädt es das Bild, das ich hoffen würde, aber pathForResource mit dem Gerät umgeht-Modifizierer, und imageWithContentsOfFile Griffe der scale-modifier.

Ich würde gerne wissen, warum. Die Dokumentation von pathForResource sagt nichts über das Gerät Modifikatoren, und die Dokumentation von imageWithContentsOfFile sagt nichts über die Skala Modifikatoren.

Gibt es eine gesonderte Dokumentation, die zeigt genau das, was jede Funktion bedeutet?

InformationsquelleAutor der Frage Jesse Beder | 2012-06-18

Schreibe einen Kommentar