2010-01-20 73 views
1

我开发了一个小型iPhone应用程序,用户可以从图像选择器中选择图像,该图像将出现在视图中。当用户首先选择一个图像时,我已将图像名称保存到数据库,并将该图像保存到具有该名称的资源文件夹中。出现主视图时,我从资源文件夹中搜索图像并在主视图中显示该图像。iPhone应用程序无法加载相册中的图像

当我在iPhone模拟器中运行此应用程序时,它成功运行,但是当我实际尝试它在我的iPhone上进行测试时,我无法在主视图中显示图像。任何人有一个想法有什么不对?

回答

4

shivang嗨,

我觉得你是保存在第一点图片NSDocumentDirectory,并试图重新加载。

  1. 而从NSDocumentDirectory retriving文件你最好 首先检查它像JPG,PNG文件类型,然后MP3给 确切名称以检索这一点。
  2. NSDocumentDirectory为每个应用程序及其 限制创建独特的内存,检查您保存的图像的大小。

更好试试这个代码

for (NSString* fileName in [fileManager contentsOfDirectoryAtPath:myfilepath error:nil]) 
{ 
if ([fileName rangeOfString:@".jpg"].location != NSNotFound ) 

    { 
     // Here fileName is used as a temporary variable to retrive image name 
     // myfilepath is the path where u stored the images 
    } 
} 
+0

它非常有用的代码。 – mareeswaran

+0

Idhellam oru polappa。 –

相关问题