【问题标题】:My images have been deleted after an app update应用更新后我的图像已被删除
【发布时间】:2012-03-02 16:26:30
【问题描述】:

我正在尝试使用 TestFlight 更新我的 iPad 应用程序,但我遇到的问题是,当我更新应用程序时,我存储的图像被删除了。

我正在使用此代码下载并稍后存储图像:

NSData *responseData = [request responseData]; 
UIImage *imageURL = [[UIImage alloc] initWithData:responseData];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(imageURL)];
[data1 writeToFile:documentsDirectory atomically:YES];
[imageURL release];

【问题讨论】:

    标签: ios ipad file


    【解决方案1】:

    您将图像直接保存在(而不是内部)Documents 目录中。它甚至不应该首先保存图像。而是在 Documents 目录下创建一个子路径并将您的文件保存在那里。

    NSString* imagePath = [documentsDirectory stringByAppendingPathComponent:@"someImage.png"];
    [data1 writeToFile:imagePath atomically:YES];
    

    【讨论】:

      【解决方案2】:

      最后解决我问题的链接是:

      Problem with NSSearchPathForDirectoriesInDomains And Persistent Data

      还是谢谢!!

      【讨论】:

        猜你喜欢
        • 2020-06-19
        • 2018-08-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-02
        • 1970-01-01
        • 2019-03-16
        • 1970-01-01
        相关资源
        最近更新 更多