2012-09-12 49 views

回答

2

NSBundle方法:

- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension 

將返回nil,如果沒有圖像被發現。

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image1" [email protected]"png"]; 
if(filePath.length > 0 && filePath != (id)[NSNull null]) { 
    UIImage *myImage = [UIImage imageWithContentsOfFile:filePath]; 
} 
+0

感謝。如果我找到它,如何獲得圖像,因爲該方法只是返回一個字符串? – soleil

+0

[UIImage imageWithContentOfFile:yourFilePath]; – J2theC

+0

我更新了我的答案。 – ohr