iPhone应用程序无法从相册加载图像

iPhone应用程序无法从相册加载图像,iphone,uiimageview,Iphone,Uiimageview,我开发了一个小型iPhone应用程序,用户可以从图像选择器中选择图像,然后图像将显示在视图中。当用户第一次选择图像时,我已将图像名称保存到数据库中,并将该图像保存到具有该名称的资源文件夹中。当主视图出现时,我从资源文件夹中搜索图像,并在主视图中显示该图像 当我在iPhone模拟器中运行此应用程序时,它成功运行,但当我在iPhone上实际尝试用于测试目的时,我无法在主视图中显示图像。有人知道这是怎么回事吗?嗨,希旺 我认为您第一次单击就将图像保存到NSDocumentDirectory并尝试重新加

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

当我在iPhone模拟器中运行此应用程序时,它成功运行,但当我在iPhone上实际尝试用于测试目的时,我无法在主视图中显示图像。有人知道这是怎么回事吗?

嗨,希旺

我认为您第一次单击就将图像保存到NSDocumentDirectory并尝试重新加载它

在从NSDocumentDirectory检索文件时,您最好 首先检查文件类型,如jpg、png、mp3,然后给出 确切的名字来检索那个。 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
  }
}
你好,shivang

我认为您第一次单击就将图像保存到NSDocumentDirectory并尝试重新加载它

在从NSDocumentDirectory检索文件时,您最好 首先检查文件类型,如jpg、png、mp3,然后给出 确切的名字来检索那个。 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
  }
}