【问题标题】:how to save image and data locally in iphone device如何在 iPhone 设备中本地保存图像和数据
【发布时间】:2010-12-29 06:48:33
【问题描述】:

我正在从 .net 网络服务器获取图像和一些详细信息。

我需要将这些详细信息存储在 iphone 设备内存中(而不是 sdcard),因为我只需要连接一次网络服务,即安装我的应用程序。

从下一次开始,我需要从设备获取数据。

我有一些java知识,在java中我使用文件来存储图像和哈希表来存储细节。

我发现这个到store image

它显示路径

/Users/appleuser/Library/Application Support/iPhone Simulator/4.0.1/Applications/14ED40D5-321E-4519-BDEA-77757589F8F7/Documents

但它是保存在设备中还是只保存在笔记本中。

我如何在 iphone 中做到这一点。

谁能帮帮我。

提前谢谢你。

【问题讨论】:

标签: iphone


【解决方案1】:

嗨,

这个方法你试过了吗

UIImageWriteToSavedPhotosAlbum(image, self, (SEL)@selector(Imageview.image:didFinishSavingWithError:contextInfo:), nil); 

【讨论】:

    【解决方案2】:

    如果您想将图像保存到您的设备相册

    UIImageWriteToSavedPhotosAlbum(image, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), context); 
    

    终于知道保存成功还是不用这个方法

    - (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
            NSString *message;
            NSString *title;
            if (!error) {
            title = NSLocalizedString(@"SaveSuccessTitle", @"");
            message = NSLocalizedString(@"SaveSuccessMessage", @"");
            }
     else {
            title = NSLocalizedString(@"SaveFailedTitle", @"");
            message = [error description];
          }
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title 
                                               message:message
                                               delegate:nil
                                               cancelButtonTitle:@"OK"
                                               otherButtonTitles:nil];
                                               [alert show];
                                               [alert release];
    

    }

    否则,如果您要检索大量数据(例如图像等),您可以在项目中实现 Coredata 以进行更复杂的操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-20
      • 1970-01-01
      • 2011-01-18
      • 1970-01-01
      • 2015-04-08
      • 2013-01-10
      • 1970-01-01
      • 2023-04-05
      相关资源
      最近更新 更多