2009-12-22 6 views
0

Voici mon codeun problème avec l'image de charge du cache sur iPhone

UIImage * result = [[UIImage alloc] imageWithContentsOfFile:filePath]; 

ici mon erreur journal

> 2009-12-22 17:00:44.137 
> DrillDownApp[2061:207] touchesBegan 
> from root 2009-12-22 17:00:44.138 
> DrillDownApp[2061:207] touchesBegan 
> from root at X = 52.000 and Y = 87.000 
> at INDEX = 0 2009-12-22 17:00:44.139 
> DrillDownApp[2061:207] index = 0 
> 2009-12-22 17:00:44.140 
> DrillDownApp[2061:207] Begin Load 
> Image 2009-12-22 17:00:44.141 
> DrillDownApp[2061:207] Load Image 
> complete 2009-12-22 17:00:44.142 
> DrillDownApp[2061:207] get index = 0 
> 2009-12-22 17:00:44.143 
> DrillDownApp[2061:207] 
> /Users/ragopor/Library/Application 
> Support/iPhone 
> Simulator/User/Applications/47C3AA6B-4C93-4A17-BF3C-D212D11951F2/Documents/URLCache/P4010143.jpg 
> 2009-12-22 17:00:44.144 
> DrillDownApp[2061:207] *** -[UIImage 
> imageWithContentsOfFile:]: 
> unrecognized selector sent to instance 
> 0x3d180b0 2009-12-22 17:00:44.144 
> DrillDownApp[2061:207] *** Terminating 
> app due to uncaught exception 
> 'NSInvalidArgumentException', reason: 
> '*** -[UIImage 
> imageWithContentsOfFile:]: 
> unrecognized selector sent to instance 
> 0x3d180b0' 2009-12-22 17:00:44.145 
> DrillDownApp[2061:207] Stack: (
>  29721691, 
>  2449544457, 
>  30103611, 
>  29673078, 
>  29525698, 
>  13756, 
>  20415, 
>  20979, 
>  25843, 
>  18694, 
>  3160730, 
>  3143896, 
>  397754, 
>  29506240, 
>  29502536, 
>  37812109, 
>  37812306, 
>  2887683, 
>  11024, 
>  10878) 
+0

UIImageView * Résultat = [[UIImageView alloc] initWithImage: [UIImage imageWithContentsOfFile: filePath]]; ce code peut résoudre mon erreur – RAGOpoR

Répondre

0

imageWithContentsOfFile est une méthode de classe. Vous devez utiliser soit

[UIImage imageWithContentsOfFile:filePath]; 

ou

[[UIImage alloc] initWithContentsOfFile:filePath]; 
+0

merci Vladimir pour la réponse – RAGOpoR

0

imageWithContentsOfFile est une fonction statique qui retourne une UIImage. Pas besoin d'allouer une image.

UIImage * result = [UIImage imageWithContentsOfFile:filePath]; 
+0

merci Fungus pour la réponse UIImage * result = [UIImage imageWithContentsOfFile: filePath]; ce code a toujours eu une erreur – RAGOpoR

+0

vous devriez appeler [résultat conserver] ainsi que –